Class NumberHelper
Number helper library.
Methods to make numbers more readable.
- AppHelper
- NumberHelper
Link: http://book.cakephp.org/2.0/en/core-libraries/helpers/number.html
See:
CakeNumber
Copyright: Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
License: MIT License
Location: Cake/View/Helper/NumberHelper.php
Properties summary
-
$_engine
protectedCakeNumber instance
Method Summary
-
__call() public
Call methods from CakeNumber utility class -
__construct() public
Default Constructor -
addFormat() public
-
currency() public
-
defaultCurrency() public
-
format() public
-
precision() public
-
toPercentage() public
-
toReadableSize() public
Method Detail
__construct() public ¶
__construct( View
$View , array $settings = array() )
Default Constructor
Settings:
engine
Class name to use to replace CakeNumber functionality The class needs to be placed in theUtility
directory.
Parameters
-
View
$View - The View this helper is being attached to.
- array $settings optional array()
- Configuration settings for the helper
Throws
addFormat() public ¶
addFormat( string $formatName , array $options )
Parameters
- string $formatName
- The format name to be used in the future.
- array $options
- The array of options for this format.
See
NumberHelper::currency()
Link
currency() public ¶
currency( float $number , string $currency = null , array $options = array() )
Parameters
- float $number
- string $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.
- array $options optional array()
Returns
Number formatted as a currency.
See
Link
defaultCurrency() public ¶
defaultCurrency( string $currency )
Parameters
- string $currency
- The currency to be used in the future.
See
NumberHelper::currency()
format() public ¶
format( float $number , integer $options = false )
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
See
Link
precision() public ¶
precision( float $number , integer $precision = 3 )
Parameters
- float $number
- A floating point number.
- integer $precision optional 3
- The precision of the returned number.
Returns
Formatted float.
See
Link
toPercentage() public ¶
toPercentage( float $number , integer $precision = 2 )
Parameters
- float $number
- A floating point number
- integer $precision optional 2
- The precision of the returned number
Returns
Percentage string
See
Link
toReadableSize() public ¶
toReadableSize( integer $size )
Parameters
- integer $size
- Size in bytes
Returns
Human readable size