1 | <?php |
||
23 | final class QuantityFormatterFactory implements QuantityFormatterFactoryInterface |
||
24 | { |
||
25 | /** |
||
26 | * @var array maps bill type to a QuantityFormatter |
||
27 | * // TODO: use DI to configure |
||
28 | */ |
||
29 | private $types = [ |
||
30 | 'monthly' => MonthlyQuantity::class, |
||
31 | |||
32 | 'monthly,rack_unit' => RackUnitQuantity::class, |
||
33 | 'ip_num' => IPNumQuantity::class, |
||
34 | 'support_time' => SupportTimeQuantity::class, |
||
35 | 'referral' => MoneyQuantity::class, |
||
36 | 'server_traf_max' => DefaultQuantityFormatter::class, |
||
37 | 'server_traf95_max' => DefaultQuantityFormatter::class, |
||
38 | 'cdn_traf_max' => DefaultQuantityFormatter::class, |
||
39 | 'backup_du' => DefaultQuantityFormatter::class, |
||
40 | 'server_du' => DefaultQuantityFormatter::class, |
||
41 | 'win_license' => DefaultQuantityFormatter::class, |
||
42 | 'hw_purchase' => DefaultQuantityFormatter::class, |
||
43 | 'server_ssd' => DefaultQuantityFormatter::class, |
||
44 | 'server_sata' => DefaultQuantityFormatter::class, |
||
45 | |||
46 | 'drenewal' => DomainRenewalQuantity::class, |
||
47 | ]; |
||
48 | /** |
||
49 | * @var IntlFormatter |
||
50 | */ |
||
51 | private $intlFormatter; |
||
52 | |||
53 | public function __construct(IntlFormatter $intlFormatter) |
||
57 | |||
58 | /** {@inheritdoc} */ |
||
59 | public function create($model): ?QuantityFormatterInterface |
||
71 | |||
72 | /** |
||
73 | * @param Bill|BillForm $bill |
||
74 | * @return QuantityFormatterInterface|null |
||
75 | */ |
||
76 | public function forBill($bill): ?QuantityFormatterInterface |
||
80 | |||
81 | public function forCharge(Charge $charge): ?QuantityFormatterInterface |
||
85 | |||
86 | public function forConsumption(Consumption $consumption): ?QuantityFormatterInterface |
||
90 | |||
91 | /** {@inheritdoc} */ |
||
92 | public function createByType(string $type, Quantity $quantity, $context = null): ?QuantityFormatterInterface |
||
115 | |||
116 | private function fixType($type): string |
||
126 | } |
||
127 |