@@ -66,13 +66,16 @@ public function __construct(View $View, $settings = array()) {
66
66
67
67
/**
68
68
* Call methods from Cake\Utility\Number utility class
69
+ *
69
70
* @return mixed Whatever is returned by called method, or false on failure
70
71
*/
71
72
public function __call ($ method , $ params ) {
72
73
return call_user_func_array (array ($ this ->_engine , $ method ), $ params );
73
74
}
74
75
75
76
/**
77
+ * Formats a number with a level of precision.
78
+ *
76
79
* @see: Cake\Utility\Number::precision()
77
80
*
78
81
* @param float $number A floating point number.
@@ -85,6 +88,8 @@ public function precision($number, $precision = 3) {
85
88
}
86
89
87
90
/**
91
+ * Returns a formatted-for-humans file size.
92
+ *
88
93
* @see: Cake\Utility\Number::toReadableSize()
89
94
*
90
95
* @param integer $size Size in bytes
@@ -96,6 +101,12 @@ public function toReadableSize($size) {
96
101
}
97
102
98
103
/**
104
+ * Formats a number into a percentage string.
105
+ *
106
+ * Options:
107
+ *
108
+ * - `multiply`: Multiply the input value by 100 for decimal percentages.
109
+ *
99
110
* @see: Cake\Utility\Number::toPercentage()
100
111
*
101
112
* @param float $number A floating point number
@@ -109,6 +120,8 @@ public function toPercentage($number, $precision = 2, $options = array()) {
109
120
}
110
121
111
122
/**
123
+ * Formats a number into a currency format.
124
+ *
112
125
* @see: Cake\Utility\Number::format()
113
126
*
114
127
* @param float $number A floating point number
@@ -122,12 +135,41 @@ public function format($number, $options = false) {
122
135
}
123
136
124
137
/**
138
+ * Formats a number into a currency format.
139
+ *
140
+ * ### Options
141
+ *
142
+ * - `wholeSymbol` - The currency symbol to use for whole numbers,
143
+ * greater than 1, or less than -1.
144
+ * - `wholePosition` - The position the whole symbol should be placed
145
+ * valid options are 'before' & 'after'.
146
+ * - `fractionSymbol` - The currency symbol to use for fractional numbers.
147
+ * - `fractionPosition` - The position the fraction symbol should be placed
148
+ * valid options are 'before' & 'after'.
149
+ * - `before` - The currency symbol to place before whole numbers
150
+ * ie. '$'. `before` is an alias for `wholeSymbol`.
151
+ * - `after` - The currency symbol to place after decimal numbers
152
+ * ie. 'c'. Set to boolean false to use no decimal symbol.
153
+ * eg. 0.35 => $0.35. `after` is an alias for `fractionSymbol`
154
+ * - `zero` - The text to use for zero values, can be a
155
+ * string or a number. ie. 0, 'Free!'
156
+ * - `places` - Number of decimal places to use. ie. 2
157
+ * - `fractionExponent` - Fraction exponent of this specific currency. Defaults to 2.
158
+ * - `thousands` - Thousands separator ie. ','
159
+ * - `decimals` - Decimal separator symbol ie. '.'
160
+ * - `negative` - Symbol for negative numbers. If equal to '()',
161
+ * the number will be wrapped with ( and )
162
+ * - `escape` - Should the output be escaped for html special characters.
163
+ * The default value for this option is controlled by the currency settings.
164
+ * By default all currencies contain utf-8 symbols and don't need this changed. If you require
165
+ * non HTML encoded symbols you will need to update the settings with the correct bytes.
166
+ *
125
167
* @see: Cake\Utility\Number::currency()
126
168
*
127
169
* @param float $number
128
170
* @param string $currency Shortcut to default options. Valid values are 'USD', 'EUR', 'GBP', otherwise
129
171
* set at least 'before' and 'after' options.
130
- * 'USD' is the default currency, use CakeNumber ::defaultCurrency() to change this default.
172
+ * 'USD' is the default currency, use Number ::defaultCurrency() to change this default.
131
173
* @param array $options
132
174
* @return string Number formatted as a currency.
133
175
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/number.html#NumberHelper::currency
@@ -137,6 +179,18 @@ public function currency($number, $currency = null, $options = array()) {
137
179
}
138
180
139
181
/**
182
+ * Add a currency format to the Number helper. Makes reusing
183
+ * currency formats easier.
184
+ *
185
+ * {{{ $number->addFormat('NOK', array('before' => 'Kr. ')); }}}
186
+ *
187
+ * You can now use `NOK` as a shortform when formatting currency amounts.
188
+ *
189
+ * {{{ $number->currency($value, 'NOK'); }}}
190
+ *
191
+ * Added formats are merged with the defaults defined in Cake\Utility\Number::$_currencyDefaults
192
+ * See Cake\Utility\Number::currency() for more information on the various options and their function.
193
+ *
140
194
* @see: Cake\Utility\Number::addFormat()
141
195
*
142
196
* @param string $formatName The format name to be used in the future.
@@ -150,7 +204,8 @@ public function addFormat($formatName, $options) {
150
204
}
151
205
152
206
/**
153
- * @see CakeNumber::defaultCurrency()
207
+ * Getter/setter for default currency
208
+ * @see Cake\Utility\Number::defaultCurrency()
154
209
*
155
210
* @param string $currency The currency to be used in the future.
156
211
* @return void
0 commit comments