Permalink
Browse files

Use ordinal constant in ordinal method, accept type options verbatim …

…in formatter method
  • Loading branch information...
bcrowe committed Sep 4, 2015
1 parent 87263dc commit afe56abf49759638e0745e85d75096877252942a
Showing with 7 additions and 8 deletions.
  1. +7 −8 src/I18n/Number.php
View
@@ -253,7 +253,7 @@ public static function defaultCurrency($currency = null)
*
* - `locale` - The locale name to use for formatting the number, e.g. fr_FR
* - `type` - The formatter type to construct, set it to `currency` if you need to format
* numbers representing money or 'ordinal' for the ordinal numbers.
* numbers representing money or a NumberFormatter constant.
* - `places` - Number of decimal places to use. e.g. 2
* - `precision` - Maximum Number of decimal places to use, e.g. 2
* - `pattern` - An ICU number pattern to use for formatting the number. e.g #,###.00
@@ -272,12 +272,11 @@ public static function formatter($options = [])
}
$type = NumberFormatter::DECIMAL;
if (!empty($options['type']) && $options['type'] === 'currency') {
$type = NumberFormatter::CURRENCY;
}
if (!empty($options['type']) && $options['type'] === 'ordinal') {
$type = NumberFormatter::ORDINAL;
if (!empty($options['type'])) {
$type = $options['type'];
if ($options['type'] === 'currency') {
$type = NumberFormatter::CURRENCY;
}
}
if (!isset(static::$_formatters[$locale][$type])) {
@@ -326,6 +325,6 @@ public static function formatter($options = [])
*/
public static function ordinal($value, array $options = [])
{
return static::formatter(['type' => 'ordinal'] + $options)->format($value);
return static::formatter(['type' => NumberFormatter::ORDINAL] + $options)->format($value);
}
}

0 comments on commit afe56ab

Please sign in to comment.