Skip to content

Commit a9261b2

Browse files
committed
Updates for ApiGen and other general edits
1 parent 80ab6f9 commit a9261b2

File tree

8 files changed

+146
-26
lines changed

8 files changed

+146
-26
lines changed

src/Utility/Number.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class Number {
8080
);
8181

8282
/**
83-
* Default currency used by CakeNumber::currency()
83+
* Default currency used by Number::currency()
8484
*
8585
* @var string
8686
*/

src/View/Helper/NumberHelper.php

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,16 @@ public function __construct(View $View, $settings = array()) {
6666

6767
/**
6868
* Call methods from Cake\Utility\Number utility class
69+
*
6970
* @return mixed Whatever is returned by called method, or false on failure
7071
*/
7172
public function __call($method, $params) {
7273
return call_user_func_array(array($this->_engine, $method), $params);
7374
}
7475

7576
/**
77+
* Formats a number with a level of precision.
78+
*
7679
* @see: Cake\Utility\Number::precision()
7780
*
7881
* @param float $number A floating point number.
@@ -85,6 +88,8 @@ public function precision($number, $precision = 3) {
8588
}
8689

8790
/**
91+
* Returns a formatted-for-humans file size.
92+
*
8893
* @see: Cake\Utility\Number::toReadableSize()
8994
*
9095
* @param integer $size Size in bytes
@@ -96,6 +101,12 @@ public function toReadableSize($size) {
96101
}
97102

98103
/**
104+
* Formats a number into a percentage string.
105+
*
106+
* Options:
107+
*
108+
* - `multiply`: Multiply the input value by 100 for decimal percentages.
109+
*
99110
* @see: Cake\Utility\Number::toPercentage()
100111
*
101112
* @param float $number A floating point number
@@ -109,6 +120,8 @@ public function toPercentage($number, $precision = 2, $options = array()) {
109120
}
110121

111122
/**
123+
* Formats a number into a currency format.
124+
*
112125
* @see: Cake\Utility\Number::format()
113126
*
114127
* @param float $number A floating point number
@@ -122,12 +135,41 @@ public function format($number, $options = false) {
122135
}
123136

124137
/**
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+
*
125167
* @see: Cake\Utility\Number::currency()
126168
*
127169
* @param float $number
128170
* @param string $currency Shortcut to default options. Valid values are 'USD', 'EUR', 'GBP', otherwise
129171
* 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.
131173
* @param array $options
132174
* @return string Number formatted as a currency.
133175
* @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()) {
137179
}
138180

139181
/**
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+
*
140194
* @see: Cake\Utility\Number::addFormat()
141195
*
142196
* @param string $formatName The format name to be used in the future.
@@ -150,7 +204,8 @@ public function addFormat($formatName, $options) {
150204
}
151205

152206
/**
153-
* @see CakeNumber::defaultCurrency()
207+
* Getter/setter for default currency
208+
* @see Cake\Utility\Number::defaultCurrency()
154209
*
155210
* @param string $currency The currency to be used in the future.
156211
* @return void

src/View/Helper/TextHelper.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,9 @@ public function autoLink($text, $options = array()) {
216216
}
217217

218218
/**
219+
* Highlights a given phrase in a text. You can specify any expression in highlighter that
220+
* may include the \1 expression to include the $phrase found.
221+
*
219222
* @see String::highlight()
220223
*
221224
* @param string $text Text to search the phrase in
@@ -252,6 +255,8 @@ public function autoParagraph($text) {
252255
}
253256

254257
/**
258+
* Strips given text of all links (<a href=....)
259+
*
255260
* @see String::stripLinks()
256261
*
257262
* @param string $text Text
@@ -263,6 +268,16 @@ public function stripLinks($text) {
263268
}
264269

265270
/**
271+
* Truncates text starting from the end.
272+
*
273+
* Cuts a string to the length of $length and replaces the first characters
274+
* with the ellipsis if the text is longer than length.
275+
*
276+
* ### Options:
277+
*
278+
* - `ellipsis` Will be used as Beginning and prepended to the trimmed string
279+
* - `exact` If false, $text will not be cut mid-word
280+
*
266281
* @see String::truncate()
267282
*
268283
* @param string $text String to truncate.
@@ -276,6 +291,9 @@ public function truncate($text, $length = 100, $options = array()) {
276291
}
277292

278293
/**
294+
* Extracts an excerpt from the text surrounding the phrase with a number of characters on each side
295+
* determined by radius.
296+
*
279297
* @see String::excerpt()
280298
*
281299
* @param string $text String to search the phrase in
@@ -290,6 +308,8 @@ public function excerpt($text, $phrase, $radius = 100, $ending = '...') {
290308
}
291309

292310
/**
311+
* Creates a comma separated list where the last two items are joined with 'and', forming natural English
312+
*
293313
* @see String::toList()
294314
*
295315
* @param array $list The list to be joined

0 commit comments

Comments
 (0)