Conditions | 2 |
Paths | 2 |
Total Lines | 13 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
24 | public function convertToCode($name, $locale = 'en') |
||
25 | { |
||
26 | $names = Intl::getCurrencyBundle()->getCurrencyNames($locale); |
||
27 | $currencyCode = array_search($name, $names, true); |
||
28 | |||
29 | if (false === $currencyCode) { |
||
30 | throw new \InvalidArgumentException(sprintf( |
||
31 | 'Currency "%s" not found! Available names: %s.', $name, implode(', ', $names) |
||
32 | )); |
||
33 | } |
||
34 | |||
35 | return $currencyCode; |
||
36 | } |
||
37 | } |
||
38 |