Common operations and tools related with numbers
package | Default |
---|
forceNumeric(mixed $value,string $valueName = '',string $errorMessage = 'must be numeric'): void
Throws |
|
---|
mixed
A value to check
string
The name of the value to be shown at the beginning of the exception message
string
The rest of the exception message
forcePositiveInteger(mixed $value,string $valueName = '',string $errorMessage = 'must be a positive integer'): void
Throws |
|
---|
mixed
A value to check
string
The name of the value to be shown at the beginning of the exception message
string
The rest of the exception message
generateRandomInteger(integer $min,integer $max): integer
Throws |
|
---|
integer
lowest possible value (negative values are allowed)
integer
highest possible value (negative values are allowed)
integer
A random integer value between min and max
getNumeric(mixed $value,string $decimalDivider = ''): \org\turbocommons\src\main\php\utils\number
mixed
A value to convert to a number
string
The decimal divider to use. Possible values are '.' and ','. If not provided, it will be auto-detected.
\org\turbocommons\src\main\php\utils\number
The numeric type representation from the given value. For example, a string '0001' will return 1
isInteger(mixed $value): boolean
mixed
A value to check
boolean
true if the given value is a numeric integer or represents a numeric integer value, false otherwise
isNumeric(mixed $value,string $decimalDivider = ''): boolean
mixed
A value to check.
string
The decimal divider to use. Possible values are '.' and ','. If not provided, it will be auto-detected.
boolean
true if the given value is numeric, false otherwise.
NON_NUMERIC_ERROR
constant | string |
---|---|