Skip to content

Commit

Permalink
Added NumberHelper::formatDelta
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Aug 2, 2014
1 parent 124189b commit e86a447
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/Utility/Number.php
Expand Up @@ -201,7 +201,6 @@ public static function format($value, array $options = []) {
* - `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 Options list.
Expand Down
22 changes: 22 additions & 0 deletions src/View/Helper/NumberHelper.php
Expand Up @@ -175,6 +175,28 @@ public function currency($number, $currency = null, array $options = array()) {
return $options['escape'] ? h($formatted): $formatted;
}

/**
* Formats a number into the correct locale format to show deltas (signed differences in value).
*
* ### Options
*
* - `places` - Minimim number or decimals to use, e.g 0
* - `precision` - Maximum Number of decimal places to use, e.g. 2
* - `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 Options list.
* @return string formatted delta
*/
public static function formatDelta($value, array $options = array()) {
$formatted = $this->_engine->formatDelta($value, $options);
$options += ['escape' => true];
return $options['escape'] ? h($formatted): $formatted;
}

/**
* Getter/setter for default currency
*
Expand Down

0 comments on commit e86a447

Please sign in to comment.