1 | <?php |
||
15 | final class QuantityFormatterFactory implements QuantityFormatterFactoryInterface |
||
16 | { |
||
17 | /** |
||
18 | * @var array maps bill type to a QuantityFormatter |
||
19 | * // TODO: use DI to configure |
||
20 | */ |
||
21 | private $types = [ |
||
22 | 'support_time' => SupportTimeQuantity::class, |
||
23 | 'server_traf_max' => DefaultQuantityFormatter::class, |
||
24 | 'server_traf95_max' => DefaultQuantityFormatter::class, |
||
25 | 'backup_du' => DefaultQuantityFormatter::class, |
||
26 | 'server_du' => DefaultQuantityFormatter::class, |
||
27 | 'hw_purchase' => DefaultQuantityFormatter::class, |
||
28 | 'ip_num' => IPNumQuantity::class, |
||
29 | 'monthly' => MonthlyQuantity::class, |
||
30 | 'drenewal' => DomainRenewalQuantity::class, |
||
31 | ]; |
||
32 | /** |
||
33 | * @var IntlFormatter |
||
34 | */ |
||
35 | private $intlFormatter; |
||
36 | |||
37 | public function __construct(IntlFormatter $intlFormatter) |
||
41 | |||
42 | /** {@inheritdoc} */ |
||
43 | public function create($model): ?QuantityFormatterInterface |
||
55 | |||
56 | /** |
||
57 | * @param Bill|BillForm $bill |
||
58 | * @return QuantityFormatterInterface|null |
||
59 | */ |
||
60 | public function forBill($bill): ?QuantityFormatterInterface |
||
64 | |||
65 | public function forCharge(Charge $charge): ?QuantityFormatterInterface |
||
69 | |||
70 | public function forConsumption(Consumption $consumption) |
||
74 | |||
75 | /** {@inheritdoc} */ |
||
76 | public function createByType(string $type, Quantity $quantity, $context = null): ?QuantityFormatterInterface |
||
92 | |||
93 | private function fixType($type): string |
||
102 | } |
||
103 |