1 | <?php |
||
23 | class CreateMoney |
||
24 | { |
||
25 | |||
26 | /** |
||
27 | * @var Calculator $calculator |
||
28 | */ |
||
29 | protected static $calculator; |
||
30 | |||
31 | /** |
||
32 | * @var MoneyFormatter[] $formatters |
||
33 | */ |
||
34 | protected static $formatters; |
||
35 | |||
36 | |||
37 | |||
38 | /** |
||
39 | * factory method that returns a Money object using amount specified in the currency's subunits |
||
40 | * example: for $12.50 USD use CreateMoney::fromSubUnits(1250, 'USD') |
||
41 | * |
||
42 | * @param int $subunits_amount money amount IN THE SUBUNITS FOR THE CURRENCY ie: cents |
||
43 | * example: $12.50 USD would equate to a subunits amount of 1250 |
||
44 | * @param string $currency_code |
||
45 | * @return Money |
||
46 | * @throws EE_Error |
||
47 | * @throws InvalidArgumentException |
||
48 | * @throws InvalidDataTypeException |
||
49 | * @throws InvalidInterfaceException |
||
50 | */ |
||
51 | public static function fromSubUnits($subunits_amount, $currency_code = '') |
||
62 | |||
63 | |||
64 | |||
65 | /** |
||
66 | * factory method that returns a Money object using the currency corresponding to the site's country |
||
67 | * example: CreateMoney::forSite(12.5) |
||
68 | * |
||
69 | * @param float|int|string $amount money amount IN THE STANDARD UNIT FOR THE CURRENCY ie: dollars, Euros, etc |
||
70 | * example: $12.5 USD would equate to a standard amount of 12.50 |
||
71 | * @return Money |
||
72 | * @throws EE_Error |
||
73 | * @throws InvalidArgumentException |
||
74 | * @throws InvalidDataTypeException |
||
75 | * @throws InvalidInterfaceException |
||
76 | */ |
||
77 | public static function forSite($amount) |
||
86 | |||
87 | |||
88 | |||
89 | /** |
||
90 | * factory method that returns a Money object using the currency as specified by the supplied ISO country code |
||
91 | * example: CreateMoney::forCountry(12.5,'US') |
||
92 | * |
||
93 | * @param float|int|string $amount money amount IN THE STANDARD UNIT FOR THE CURRENCY ie: dollars, Euros, etc |
||
94 | * example: $12.5 USD would equate to a value amount of 12.50 |
||
95 | * @param string $CNT_ISO |
||
96 | * @return Money |
||
97 | * @throws EE_Error |
||
98 | * @throws InvalidArgumentException |
||
99 | * @throws InvalidDataTypeException |
||
100 | * @throws InvalidInterfaceException |
||
101 | */ |
||
102 | public static function forCountry($amount, $CNT_ISO) |
||
111 | |||
112 | |||
113 | |||
114 | /** |
||
115 | * factory method that returns a Money object using the currency as specified by the supplied currency code |
||
116 | * example: CreateMoney::forCurrency(12.5, 'USD') |
||
117 | * |
||
118 | * @param float|int|string $amount money amount IN THE STANDARD UNIT FOR THE CURRENCY ie: dollars, Euros, etc |
||
119 | * example: $12.5 USD would equate to a value amount of 12.50 |
||
120 | * @param string $currency_code |
||
121 | * @return Money |
||
122 | * @throws EE_Error |
||
123 | * @throws InvalidArgumentException |
||
124 | * @throws InvalidDataTypeException |
||
125 | * @throws InvalidInterfaceException |
||
126 | */ |
||
127 | public static function forCurrency($amount, $currency_code) |
||
136 | |||
137 | |||
138 | |||
139 | |||
140 | /** |
||
141 | * @return Calculator |
||
142 | */ |
||
143 | public static function calculator() |
||
148 | |||
149 | |||
150 | |||
151 | /** |
||
152 | * loops through a filterable array of Calculator services |
||
153 | * and selects the first one that is supported by the current server |
||
154 | */ |
||
155 | protected static function initializeCalculators() |
||
177 | |||
178 | |||
179 | |||
180 | /** |
||
181 | * @return MoneyFormatter[] |
||
182 | */ |
||
183 | public static function formatters() |
||
188 | |||
189 | |||
190 | |||
191 | /** |
||
192 | * initializes a filterable array of MoneyFormatter services |
||
193 | */ |
||
194 | protected static function initializeFormatters() |
||
210 | |||
211 | |||
212 | } |
||
213 | // End of file CreateMoney.php |
||
215 |