_init()
bytes()
format()
format_bytes()
format_exp()
format_phone()
mask_credit_card()
mask_string()
quantity()
smart_format_phone()
$byte_units
$config
Numeric helper class.
Provides additional formatting methods for working with numeric values.
Credit is left where credit is due.
Techniques and inspiration were taken from all over, including: Kohana Framework: kohanaframework.org CakePHP: cakephp.org
| package | Fuel |
|---|---|
| category | Core |
| author | Chase "Syntaqx" Hutchins |
_init() : void
bytes(string $size) : float
File sizes are defined in the format: SB, where S is the size (1, 8.5, 300, etc.) and B is the byte unit (K, MiB, GB, etc.). All valid byte units are defined in static::$byte_units
Usage:
echo Num::bytes('200K'); // 204800
echo static::bytes('5MiB'); // 5242880
echo static::bytes('1000'); // 1000
echo static::bytes('2.5GB'); // 2684354560
| author | Kohana Team |
|---|---|
| copyright | (c) 2009-2011 Kohana Team |
| license | http://kohanaframework.org/license |
stringfile size in SB format
floatformat(string $string, string $format) : string
Usage:
echo Num::format('1234567890', '(000) 000-0000'); // (123) 456-7890
echo Num::format('1234567890', '000.000.0000'); // 123.456.7890
| link | http://snippets.symfony-project.org/snippet/157 |
|---|
stringthe string to format
stringthe format to apply
stringformat_bytes($bytes, $decimals) : boolean | string
Supports TB value.
Note: Integers in PHP are limited to 32 bits, unless they are on 64 bit architectures, then they have 64 bit size. If you need to place the larger size then what the PHP integer type will hold, then use a string. It will be converted to a double, which should always have 64 bit length.
integer
integer
booleanstring
format_exp(string $string, string $format)
Expects 4-digit string (MMYY).
| see | \Fuel\Core\format |
|---|
stringthe unformatted expiration string to format
stringthe format to use, defaults to '00-00'
format_phone(string $string, string $format) : string
| link | http://snippets.symfony-project.org/snippet/157 |
|---|---|
| see | \Fuel\Core\format |
stringthe unformatted phone number to format
stringthe format to use, defaults to '(000) 000-0000'
stringthe formatted stringmask_credit_card(string $string, string $format)
| see | \Fuel\Core\mask_string |
|---|
stringthe unformatted credit card number to format
stringthe format to use, defaults to '**** **** **** 0000'
mask_string(string $string, string $format, string $ignore) : string
Usage:
echo Num::mask_string('1234567812345678', '************0000'); ************5678
echo Num::mask_string('1234567812345678', '**** **** **** 0000'); // **** **** **** 5678
echo Num::mask_string('1234567812345678', '**** - **** - **** - 0000', ' -'); // **** - **** - **** - 5678
| link | http://snippets.symfony-project.org/snippet/157 |
|---|
stringthe string to transform
stringthe mask format
stringa string (defaults to a single space) containing characters to ignore in the format
stringthe masked stringquantity($num, $decimals) : string
Usage:
echo Num::quantity(7000); // 7K
echo Num::quantity(7500); // 8K
echo Num::quantity(7500, 1); // 7.5K
integer
integer
stringsmart_format_phone(string $string)
Usage:
echo Num::smart_format_phone('1234567'); // 123-4567
echo Num::smart_format_phone('1234567890'); // (123) 456-7890
echo Num::smart_format_phone('91234567890'); // 9 (123) 456-7890
echo Num::smart_format_phone('123456'); // => 123456
| see | \Fuel\Core\format |
|---|
stringthe unformatted phone number to format
$byte_units : array
$config : array