| 1 | <?php |
||
| 13 | class NumberHumanizerExtension extends AbstractHumanizerExtension |
||
| 14 | { |
||
| 15 | /** |
||
| 16 | * {@inheritdoc} |
||
| 17 | */ |
||
| 18 | 45 | public function getFilters() |
|
| 19 | { |
||
| 20 | return [ |
||
| 21 | 45 | new Twig_SimpleFilter( |
|
| 22 | 45 | 'ordinalize', |
|
| 23 | 30 | function ($number) { |
|
| 24 | 3 | return NumberHumanizer::ordinalize( |
|
| 25 | 2 | $number, |
|
| 26 | 3 | $this->translator->getLocale() |
|
| 27 | 1 | ); |
|
| 28 | 30 | } |
|
| 29 | 15 | ), |
|
| 30 | 30 | new Twig_SimpleFilter('ordinal', function ($number) { |
|
| 31 | 3 | return NumberHumanizer::ordinal( |
|
| 32 | 2 | $number, |
|
| 33 | 3 | $this->translator->getLocale() |
|
| 34 | 1 | ); |
|
| 35 | 45 | }), |
|
| 36 | 45 | new Twig_SimpleFilter( |
|
| 37 | 45 | 'binary_suffix', |
|
| 38 | 30 | function ($number) { |
|
| 39 | 3 | return NumberHumanizer::binarySuffix( |
|
| 40 | 2 | $number, |
|
| 41 | 3 | $this->translator->getLocale() |
|
| 42 | 1 | ); |
|
| 43 | 30 | } |
|
| 44 | 15 | ), |
|
| 45 | 45 | new Twig_SimpleFilter( |
|
| 46 | 45 | 'precise_binary_suffix', |
|
| 47 | 30 | function ($number, $precision) { |
|
| 48 | 3 | return NumberHumanizer::preciseBinarySuffix( |
|
| 49 | 2 | $number, |
|
| 50 | 2 | $precision, |
|
| 51 | 3 | $this->translator->getLocale() |
|
| 52 | 1 | ); |
|
| 53 | 30 | } |
|
| 54 | 15 | ), |
|
| 55 | 45 | new Twig_SimpleFilter( |
|
| 56 | 45 | 'metric_suffix', |
|
| 57 | 31 | function ($number) { |
|
| 58 | 3 | return NumberHumanizer::metricSuffix( |
|
| 59 | 2 | $number, |
|
| 60 | 3 | $this->translator->getLocale() |
|
| 61 | 1 | ); |
|
| 62 | 30 | } |
|
| 63 | 15 | ), |
|
| 64 | 45 | new Twig_SimpleFilter( |
|
| 65 | 45 | 'to_roman', |
|
| 66 | 45 | [NumberHumanizer::class, 'toRoman'] |
|
| 67 | 15 | ), |
|
| 68 | 45 | new Twig_SimpleFilter( |
|
| 69 | 45 | 'from_roman', |
|
| 70 | 45 | [NumberHumanizer::class, 'fromRoman'] |
|
| 71 | 15 | ), |
|
| 72 | 15 | ]; |
|
| 73 | } |
||
| 74 | |||
| 75 | 15 | public function getName() |
|
| 79 | } |
||
| 80 |