Documentation
Number
The number helper contains methods that can be useful when working with numbers.
byteFormat(integer $size)
Convert bytes in 'kb','mb','gb','tb','pb'
echo Number::byteFormat(10000);
quantity(integer $num, [integer $decimals = 0])
Converts a number into a more readable human-type number.
echo Number::quantity(7000); // 7K echo Number::quantity(7500); // 8K echo Number::quantity(7500, 1); // 7.5K
between(integer $minimum, integer $maximum, integer $value)
Checks if the value is between the minimum and maximum (min & max included).
if (Number::between(2, 10, 5)) { // do something... }
even(integer $value)
Checks the value for an even number.
if (Number::even(2)) { // do something... }
greaterThan(integer $minimum, integer $value)
Checks if the value is greather than a given minimum.
if (Number::greaterThan(2, 10)) { // do something... }
smallerThan(integer $maximum, integer $value)
Checks if the value is smaller than a given maximum.
if (Number::smallerThan(2, 10)) { // do something... }
maximum(integer $maximum, integer $value)
Checks if the value is not greater than or equal a given maximum.
if (Number::maximum(2, 10)) { // do something... }
minimum(integer $maximum, integer $value)
Checks if the value is greater than or equal to a given minimum.
if (Number::minimum(2, 10)) { // do something... }
odd(integer $value)
Checks if the value is greater than or equal to a given minimum.
if (Number::odd(2)) { // do something... }