Total Complexity | 5 |
Total Lines | 50 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
10 | final class LocalizedCurrency extends LocalizedObjectWithFormatter |
||
11 | { |
||
12 | /** |
||
13 | * @var string The localized name of the currency. |
||
14 | */ |
||
15 | public readonly string $name; |
||
16 | |||
17 | /** |
||
18 | * @var string The localized symbol of the currency. |
||
19 | */ |
||
20 | public readonly string $symbol; |
||
21 | |||
22 | public function __construct(object $target, Locale $locale) |
||
23 | { |
||
24 | $l = $locale['currencies'][$target->code]; |
||
25 | $this->name = $l['displayName']; |
||
|
|||
26 | // Not all currencies have a symbol, we default to the currency code in those cases. |
||
27 | $this->symbol = $l['symbol'] ?? $target->code; |
||
28 | |||
29 | parent::__construct($target, $locale, $locale->currency_formatter); |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | * Returns the localized name of the currency. |
||
34 | * |
||
35 | * @param int|null $count Used for pluralization. |
||
36 | */ |
||
37 | public function name_for(int $count = null): string |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * Formats currency using locale's conventions. |
||
52 | * |
||
53 | * @param float|int|numeric-string $number |
||
54 | */ |
||
55 | public function format( |
||
60 | } |
||
61 | } |
||
62 |