Number helper library.
Methods to make numbers more readable.
NumberHelper CakeNumber$_engine protected Add a currency format to the Number helper. Makes reusing currency formats easier.
__call( string $method , array $params )
Call methods from CakeNumber utility class
$method $params __construct( View $View , array $settings array() )
Default Constructor
engine Class name to use to replace CakeNumber functionality The class needs to be placed in the Utility directory.View $View $settings optional array() CakeExceptionaddFormat( string $formatName , array $options )
Add a currency format to the Number helper. Makes reusing currency formats easier.
$this->Number->addFormat('NOK', array('before' => 'Kr. ')); ```
You can now use `NOK` as a shortform when formatting currency amounts. $this->Number->currency($value, 'NOK'); ```
Added formats are merged with the defaults defined in Cake\Utility\Number::$_currencyDefaults See Cake\Utility\Number::currency() for more information on the various options and their function.
$formatName $options currency( float $number , string $currency null , array $options array() )
Formats a number into a currency format.
$number $currency optional null Shortcut to default options. Valid values are 'USD', 'EUR', 'GBP', otherwise set at least 'before' and 'after' options. 'USD' is the default currency, use CakeNumber::defaultCurrency() to change this default.
$options optional array() defaultCurrency( string $currency )
Getter/setter for default currency
$currency format( float $number , integer $options false )
Formats a number into a currency format.
$number $options optional false If integer then places, if string then before, if (,.-) then use it or array with places and before keys
precision( float $number , integer $precision 3 )
Formats a number with a level of precision.
$number $precision optional 3 toPercentage( float $number , integer $precision 2 , array $options array() )
Formats a number into a percentage string.
Options:
multiply: Multiply the input value by 100 for decimal percentages.$number $precision optional 2 $options optional array() toReadableSize( integer $size )
Returns a formatted-for-humans file size.
$size
© 2005–2016 The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/2.9/class-NumberHelper.html