Skip to content

Commit

Permalink
Making CakeNumber::addFormat static so it is easier to configure glob…
Browse files Browse the repository at this point in the history
…ally for the app
  • Loading branch information
lorenzo authored and rchavik committed Feb 10, 2012
1 parent 2dc9986 commit fd17e33
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/Cake/Utility/CakeNumber.php
Expand Up @@ -35,7 +35,7 @@ class CakeNumber {
*
* @var array
*/
protected $_currencies = array(
protected static $_currencies = array(
'USD' => array(
'wholeSymbol' => '$', 'wholePosition' => 'before', 'fractionSymbol' => 'c', 'fractionPosition' => 'after',
'zero' => 0, 'places' => 2, 'thousands' => ',', 'decimals' => '.', 'negative' => '()', 'escape' => true
Expand All @@ -55,7 +55,7 @@ class CakeNumber {
*
* @var array
*/
protected $_currencyDefaults = array(
protected static $_currencyDefaults = array(
'wholeSymbol' => '', 'wholePosition' => 'before', 'fractionSymbol' => '', 'fractionPosition' => 'after',
'zero' => '0', 'places' => 2, 'thousands' => ',', 'decimals' => '.','negative' => '()', 'escape' => true,
);
Expand Down Expand Up @@ -173,10 +173,10 @@ public function format($number, $options = false) {
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/number.html#NumberHelper::currency
*/
public function currency($number, $currency = 'USD', $options = array()) {
$default = $this->_currencyDefaults;
$default = self::$_currencyDefaults;

if (isset($this->_currencies[$currency])) {
$default = $this->_currencies[$currency];
if (isset(self::$_currencies[$currency])) {
$default = self::$_currencies[$currency];
} elseif (is_string($currency)) {
$options['before'] = $currency;
}
Expand Down Expand Up @@ -248,7 +248,7 @@ public function currency($number, $currency = 'USD', $options = array()) {
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/number.html#NumberHelper::addFormat
*/
public function addFormat($formatName, $options) {
$this->_currencies[$formatName] = $options + $this->_currencyDefaults;
self::$_currencies[$formatName] = $options + self::$_currencyDefaults;
}

}

0 comments on commit fd17e33

Please sign in to comment.