diff --git a/src/Utility/Number.php b/src/Utility/Number.php index 1a00b26eaee..40a7f909f7c 100644 --- a/src/Utility/Number.php +++ b/src/Utility/Number.php @@ -26,45 +26,6 @@ */ class Number { -/** - * Currencies supported by the helper. You can add additional currency formats - * with Cake\Utility\Number::addFormat - * - * @var array - */ - protected static $_currencies = array( - 'AUD' => array( - 'wholeSymbol' => '$', 'wholePosition' => 'before', 'fractionSymbol' => 'c', 'fractionPosition' => 'after', - 'zero' => 0, 'places' => 2, 'thousands' => ',', 'decimals' => '.', 'negative' => '()', 'escape' => true, - 'fractionExponent' => 2 - ), - 'CAD' => array( - 'wholeSymbol' => '$', 'wholePosition' => 'before', 'fractionSymbol' => 'c', 'fractionPosition' => 'after', - 'zero' => 0, 'places' => 2, 'thousands' => ',', 'decimals' => '.', 'negative' => '()', 'escape' => true, - 'fractionExponent' => 2 - ), - 'USD' => array( - 'wholeSymbol' => '$', 'wholePosition' => 'before', 'fractionSymbol' => 'c', 'fractionPosition' => 'after', - 'zero' => 0, 'places' => 2, 'thousands' => ',', 'decimals' => '.', 'negative' => '()', 'escape' => true, - 'fractionExponent' => 2 - ), - 'EUR' => array( - 'wholeSymbol' => '€', 'wholePosition' => 'before', 'fractionSymbol' => false, 'fractionPosition' => 'after', - 'zero' => 0, 'places' => 2, 'thousands' => '.', 'decimals' => ',', 'negative' => '()', 'escape' => true, - 'fractionExponent' => 0 - ), - 'GBP' => array( - 'wholeSymbol' => '£', 'wholePosition' => 'before', 'fractionSymbol' => 'p', 'fractionPosition' => 'after', - 'zero' => 0, 'places' => 2, 'thousands' => ',', 'decimals' => '.', 'negative' => '()', 'escape' => true, - 'fractionExponent' => 2 - ), - 'JPY' => array( - 'wholeSymbol' => '¥', 'wholePosition' => 'before', 'fractionSymbol' => false, 'fractionPosition' => 'after', - 'zero' => 0, 'places' => 2, 'thousands' => ',', 'decimals' => '.', 'negative' => '()', 'escape' => true, - 'fractionExponent' => 0 - ), - ); - /** * A list of number formatters indexed by locale * @@ -195,7 +156,6 @@ public static function toPercentage($value, $precision = 2, array $options = arr * - `locale` - The locale name to use for formatting the number, e.g. fr_FR * - `before` - The string to place before whole numbers, e.g. '[' * - `after` - The string to place after decimal numbers, e.g. ']' - * - `escape` - Set to false to prevent escaping * * @param float $value A floating point number. * @param array $options An array with options. @@ -225,13 +185,9 @@ public static function format($value, array $options = []) { } } - $options += ['before' => '', 'after' => '', 'escape' => true]; + $options += ['before' => '', 'after' => '']; $out = $options['before'] . $formatter->format($value) . $options['after']; - if (!empty($options['escape'])) { - return h($out); - } - return $out; } @@ -335,29 +291,6 @@ public static function currency($value, $currency = null, array $options = array return $before . $formatter->formatCurrency($value, $currency) . $after; } -/** - * Add a currency format to the Number helper. Makes reusing - * currency formats easier. - * - * {{{ $number->addFormat('NOK', array('before' => 'Kr. ')); }}} - * - * You can now use `NOK` as a shortform when formatting currency amounts. - * - * {{{ $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. - * - * @param string $formatName The format name to be used in the future. - * @param array $options The array of options for this format. - * @return void - * @see NumberHelper::currency() - * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/number.html#NumberHelper::addFormat - */ - public static function addFormat($formatName, array $options) { - static::$_currencies[$formatName] = $options + static::$_currencyDefaults; - } - /** * Getter/setter for default currency *