Class NumberHelper
Number helper library.
Methods to make numbers more readable.
- AppHelper
- NumberHelper
Copyright: Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
License: The MIT License
Location: view/helpers/number.php
Method Summary
-
currency() public
Formats a number into a currency format. -
format() public
Formats a number into a currency format. -
precision() public
Formats a number with a level of precision. -
toPercentage() public
Formats a number into a percentage string. -
toReadableSize() public
Returns a formatted-for-humans file size.
Method Detail
currency() public ¶
currency( float $number , string $currency = 'USD' , array $options = array() )
Formats a number into a currency format.
Parameters
- float $number
- string $currency optional 'USD'
Shortcut to default options. Valid values are 'USD', 'EUR', 'GBP', otherwise set at least 'before' and 'after' options.
- array $options optional array()
Returns
Number formatted as a currency.
format() public ¶
format( float $number , integer $options = false )
Formats a number into a currency format.
Parameters
- float $number
- A floating point number
- integer $options optional false
if int then places, if string then before, if (,.-) then use it or array with places and before keys
Returns
formatted number
precision() public ¶
precision( float $number , integer $precision = 3 )
Formats a number with a level of precision.
Parameters
- float $number
- A floating point number.
- integer $precision optional 3
- The precision of the returned number.
Returns
Enter description here...
toPercentage() public ¶
toPercentage( float $number , integer $precision = 2 )
Formats a number into a percentage string.
Parameters
- float $number
- A floating point number
- integer $precision optional 2
- The precision of the returned number
Returns
Percentage string
toReadableSize() public ¶
toReadableSize( integer $size )
Returns a formatted-for-humans file size.
Parameters
- integer $size
- $length Size in bytes
Returns
Human readable size