PluginProbe ʕ •ᴥ•ʔ
VikAppointments Services Booking Calendar / 1.2.21
VikAppointments Services Booking Calendar v1.2.21
1.2.21 1.2.20 trunk 1.2.17 1.2.18 1.2.19
vikappointments / site / helpers / libraries / currency / helper / enum.php
vikappointments / site / helpers / libraries / currency / helper Last commit date
cacheable.php 5 days ago enum.php 5 days ago
enum.php
347 lines
1 <?php
2 /**
3 * @package VikAppointments
4 * @subpackage core
5 * @author E4J s.r.l.
6 * @copyright Copyright (C) 2021 E4J s.r.l. All Rights Reserved.
7 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
8 * @link https://vikwp.com
9 */
10
11 // No direct access
12 defined('ABSPATH') or die('No script kiddies please!');
13
14 /**
15 * Currency enumeration helper.
16 *
17 * @since 1.7.6
18 */
19 final class VAPCurrencyHelperEnum
20 {
21 /**
22 * Returns the metadata information of the specified currency.
23 *
24 * @param string $currency The currency code to look for (ISO 4217).
25 *
26 * @return array The currency metadata.
27 *
28 * @throws DomainException
29 */
30 public static function getMetadata(string $currency)
31 {
32 // fetch all the supported currencies
33 $currencies = static::getCurrencies();
34
35 $currency = strtoupper($currency);
36
37 if (!isset($currencies[$currency]))
38 {
39 // currency not supported
40 throw new DomainException('Cannot find [' . $currency . '] currency metadata');
41 }
42
43 return $currencies[$currency];
44 }
45
46 /**
47 * Returns an associative array containing the most common currencies
48 * and the related formatting information.
49 *
50 * @return array
51 */
52 public static function getCurrencies()
53 {
54 static $currencies = null;
55
56 if (!$currencies)
57 {
58 return [
59 'EUR' => [
60 'currency' => 'Euro',
61 'symbol' => '',
62 'position' => 2,
63 'decimals' => 2,
64 'separator' => ',',
65 'space' => true,
66 ],
67 'USD' => [
68 'currency' => 'US Dollar',
69 'symbol' => '$',
70 'position' => 2,
71 'decimals' => 2,
72 'separator' => '.',
73 'space' => true,
74 ],
75 'GBP' => [
76 'currency' => 'Pound Sterling',
77 'symbol' => '£',
78 'position' => 2,
79 'decimals' => 2,
80 'separator' => '.',
81 'space' => false,
82 ],
83 'JPY' => [
84 'currency' => 'Yen',
85 'symbol' => '¥',
86 'position' => 2,
87 'decimals' => 0,
88 'separator' => '.',
89 'space' => true,
90 ],
91 'ARS' => [
92 'currency' => 'Argentine Peso',
93 'symbol' => '$',
94 'position' => 2,
95 'decimals' => 2,
96 'separator' => ',',
97 'space' => true,
98 ],
99 'AUD' => [
100 'currency' => 'Australian Dollar',
101 'symbol' => '$',
102 'position' => 2,
103 'decimals' => 2,
104 'separator' => '.',
105 'space' => false,
106 ],
107 'BRL' => [
108 'currency' => 'Brazilian Real',
109 'symbol' => 'R$',
110 'position' => 2,
111 'decimals' => 2,
112 'separator' => ',',
113 'space' => false,
114 ],
115 'CAD' => [
116 'currency' => 'Canadian Dollar',
117 'symbol' => '$',
118 'position' => 2,
119 'decimals' => 2,
120 'separator' => '.',
121 'space' => false,
122 ],
123 'CLP' => [
124 'currency' => 'Chilean Peso',
125 'symbol' => '$',
126 'position' => 2,
127 'decimals' => 2,
128 'separator' => '.',
129 'space' => false,
130 ],
131 'CNY' => [
132 'currency' => 'Yuan Renminbi',
133 'symbol' => '¥',
134 'position' => 2,
135 'decimals' => 2,
136 'separator' => '.',
137 'space' => true,
138 ],
139 'COP' => [
140 'currency' => 'Colombian Peso',
141 'symbol' => '$',
142 'position' => 2,
143 'decimals' => 2,
144 'separator' => '.',
145 'space' => true,
146 ],
147 'CZK' => [
148 'currency' => 'Czech Koruna',
149 'symbol' => '',
150 'position' => 1,
151 'decimals' => 2,
152 'separator' => ',',
153 'space' => true,
154 ],
155 'DKK' => [
156 'currency' => 'Danish Krone',
157 'symbol' => 'kr.',
158 'position' => 2,
159 'decimals' => 2,
160 'separator' => ',',
161 'space' => false,
162 ],
163 'HKD' => [
164 'currency' => 'Hong Kong Dollar',
165 'symbol' => 'HK$',
166 'position' => 2,
167 'decimals' => 2,
168 'separator' => '.',
169 'space' => false,
170 ],
171 'HUF' => [
172 'currency' => 'Hungarian Forint',
173 'symbol' => 'Ft',
174 'position' => 1,
175 'decimals' => 2,
176 'separator' => ',',
177 'space' => true,
178 ],
179 'INR' => [
180 'currency' => 'Indian Rupee',
181 'symbol' => '',
182 'position' => 2,
183 'decimals' => 2,
184 'separator' => '.',
185 'space' => false,
186 ],
187 'ILS' => [
188 'currency' => 'New Israeli Shekel',
189 'symbol' => '',
190 'position' => 2,
191 'decimals' => 2,
192 'separator' => ',',
193 'space' => true,
194 ],
195 'KRW' => [
196 'currency' => 'Won',
197 'symbol' => '',
198 'position' => 2,
199 'decimals' => 2,
200 'separator' => '.',
201 'space' => false,
202 ],
203 'MYR' => [
204 'currency' => 'Malaysian Ringgit',
205 'symbol' => 'RM',
206 'position' => 2,
207 'decimals' => 2,
208 'separator' => '.',
209 'space' => true,
210 ],
211 'MXN' => [
212 'currency' => 'Mexican Peso',
213 'symbol' => '$',
214 'position' => 2,
215 'decimals' => 2,
216 'separator' => '.',
217 'space' => false,
218 ],
219 'MAD' => [
220 'currency' => 'Moroccan Dirham',
221 'symbol' => '.د.�
222 .',
223 'position' => 1,
224 'decimals' => 2,
225 'separator' => '.',
226 'space' => true,
227 ],
228 'NZD' => [
229 'currency' => 'New Zealand Dollar',
230 'symbol' => '$',
231 'position' => 2,
232 'decimals' => 2,
233 'separator' => '.',
234 'space' => false,
235 ],
236 'NOK' => [
237 'currency' => 'Norwegian Krone',
238 'symbol' => 'kr',
239 'position' => 2,
240 'decimals' => 2,
241 'separator' => '.',
242 'space' => false,
243 ],
244 'PHP' => [
245 'currency' => 'Philippine Peso',
246 'symbol' => '',
247 'position' => 2,
248 'decimals' => 2,
249 'separator' => '.',
250 'space' => false,
251 ],
252 'PLN' => [
253 'currency' => 'Zloty',
254 'symbol' => '',
255 'position' => 1,
256 'decimals' => 2,
257 'separator' => ',',
258 'space' => true,
259 ],
260 'RUB' => [
261 'currency' => 'Russian Ruble',
262 'symbol' => 'p.',
263 'position' => 1,
264 'decimals' => 2,
265 'separator' => ',',
266 'space' => true,
267 ],
268 'SAR' => [
269 'currency' => 'Saudi Riyal',
270 'symbol' => '',
271 'position' => 1,
272 'decimals' => 2,
273 'separator' => '.',
274 'space' => true,
275 ],
276 'SGD' => [
277 'currency' => 'Singapore Dollar',
278 'symbol' => '$',
279 'position' => 2,
280 'decimals' => 2,
281 'separator' => '.',
282 'space' => true,
283 ],
284 'ZAR' => [
285 'currency' => 'Rand',
286 'symbol' => 'R',
287 'position' => 2,
288 'decimals' => 2,
289 'separator' => '.',
290 'space' => false,
291 ],
292 'SEK' => [
293 'currency' => 'Swedish Krona',
294 'symbol' => 'kr',
295 'position' => 1,
296 'decimals' => 2,
297 'separator' => ',',
298 'space' => true,
299 ],
300 'CHF' => [
301 'currency' => 'Swiss Franc',
302 'symbol' => 'fr.',
303 'position' => 2,
304 'decimals' => 2,
305 'separator' => ',',
306 'space' => true,
307 ],
308 'TWD' => [
309 'currency' => 'New Taiwan Dollar',
310 'symbol' => '�
311 �',
312 'position' => 2,
313 'decimals' => 2,
314 'separator' => '.',
315 'space' => true,
316 ],
317 'THB' => [
318 'currency' => 'Baht',
319 'symbol' => '฿',
320 'position' => 1,
321 'decimals' => 2,
322 'separator' => '.',
323 'space' => true,
324 ],
325 'TRY' => [
326 'currency' => 'Turkish Lira',
327 'symbol' => '',
328 'position' => 1,
329 'decimals' => 2,
330 'separator' => '.',
331 'space' => false,
332 ],
333 'VND' => [
334 'currency' => 'Dong',
335 'symbol' => '',
336 'position' => 1,
337 'decimals' => 2,
338 'separator' => ',',
339 'space' => true,
340 ],
341 ];
342 }
343
344 return $currencies;
345 }
346 }
347