Conditions | 2 |
Paths | 2 |
Total Lines | 13 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
24 | public function format($amount, $currency, $locale = 'en') |
||
25 | { |
||
26 | $formatter = new \NumberFormatter($locale, \NumberFormatter::CURRENCY); |
||
27 | |||
28 | $result = $formatter->formatCurrency(abs($amount / 100), $currency); |
||
29 | Assert::notSame( |
||
30 | false, |
||
31 | $result, |
||
32 | sprintf('The amount "%s" of type %s cannot be formatted to currency "%s".', $amount, gettype($amount), $currency) |
||
33 | ); |
||
34 | |||
35 | return $amount >= 0 ? $result : '-' . $result; |
||
36 | } |
||
37 | } |
||
38 |