CSNumberUtils
in package
Collection of various convenience methods regarding number operations
This class offers a set of methods that will be helpful to work with numbers in PHP.
Tags
Table of Contents
- convertToPixel() : int
- Convert image size parameters(width, height) from given measure units to pixel.
- splitRangeIntoRanges() : array<string|int, mixed>
- Splits a certain Range into smaller ranges with a given limit
- validatePrecision() : bool
- Validates Number/Float precision, by comparing the original string value with the float value.
Methods
convertToPixel()
Convert image size parameters(width, height) from given measure units to pixel.
public
static convertToPixel(string $sValue) : int
Parameters
- $sValue : string
-
Value with measure unit.
Tags
Return values
int —converted value of parameter to pixel.
splitRangeIntoRanges()
Splits a certain Range into smaller ranges with a given limit
public
static splitRangeIntoRanges(int $iRangeStart, int $iRangeEnd[, int $iRangeLimit = 10 ]) : array<string|int, mixed>
Parameters
- $iRangeStart : int
-
The initial range start
- $iRangeEnd : int
-
The ranges end
- $iRangeLimit : int = 10
-
The limit the new ranges may have
Tags
Return values
array<string|int, mixed> —An array containing arrays with "Start" and "End" as Key. The last Range will not exceed the initial range end
validatePrecision()
Validates Number/Float precision, by comparing the original string value with the float value.
public
static validatePrecision(string $sNumberValue, string $sDecimalSep, string $sThousandsSep) : bool
Parameters
- $sNumberValue : string
-
String representation of the number that should be validated
- $sDecimalSep : string
-
The decimal separator of the value
- $sThousandsSep : string
-
The thousand separator of the value
Tags
Return values
bool —$bIsNumberValid TRUE if value can be converted without any precision loss. FALSE if precision is lost.
