1 | <?php |
||
20 | class Service |
||
21 | { |
||
22 | /** |
||
23 | * Container hổ trợ việc lấy các service từ điển. |
||
24 | * |
||
25 | * @var ContainerInterface |
||
26 | */ |
||
27 | protected $container; |
||
28 | |||
29 | /** |
||
30 | * Chứa thông tin cấu hình từ dev. |
||
31 | * |
||
32 | * @var array |
||
33 | */ |
||
34 | protected $config; |
||
35 | |||
36 | /** |
||
37 | * Khởi tạo dịch vụ chuyển đổi số sang chữ số. |
||
38 | * |
||
39 | * @param ContainerInterface $container |
||
40 | * @param array $config |
||
41 | */ |
||
42 | public function __construct(ContainerInterface $container, array $config = []) |
||
47 | |||
48 | /** |
||
49 | * Chuyển đổi số sang chữ số. |
||
50 | * |
||
51 | * @param string|int|float $number |
||
52 | * @param string|null $dictionary |
||
53 | * @return string |
||
54 | */ |
||
55 | public function toWords($number, ?string $dictionary = null): string |
||
62 | |||
63 | /** |
||
64 | * Chuyển đổi số sang tiền tệ. |
||
65 | * |
||
66 | * @param string|float|int $number |
||
67 | * @param array|string[]|string $unit |
||
68 | * @param string|null $dictionary |
||
69 | * @return string |
||
70 | */ |
||
71 | public function toCurrency($number, $unit = 'đồng', ?string $dictionary = null): string |
||
78 | |||
79 | /** |
||
80 | * Khởi tạo đối tượng hổ trợ việc chuyển đổi. |
||
81 | * |
||
82 | * @param DictionaryInterface|null $dictionary |
||
83 | * @return Transformer |
||
84 | */ |
||
85 | protected function createTransformer(?DictionaryInterface $dictionary): Transformer |
||
89 | |||
90 | /** |
||
91 | * Trả về từ điển dùng để chuyển đổi số sang chữ số. |
||
92 | * |
||
93 | * @param string|null $dictionary |
||
94 | * @return DictionaryInterface|null |
||
95 | */ |
||
96 | protected function getDictionaryInstance(?string $dictionary): ?DictionaryInterface |
||
106 | |||
107 | /** |
||
108 | * Trả về từ điển mặc định nếu không chỉ định. |
||
109 | * |
||
110 | * @return string |
||
111 | */ |
||
112 | protected function getDefaultDictionary(): string |
||
116 | } |
||
117 |