PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 4.16.6.1
GiveWP – Donation Plugin and Fundraising Platform v4.16.6.1
4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 2.31.0 2.31.1 2.32.0 2.33.0 2.33.1 2.33.2 2.33.3 2.33.4 2.33.5 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.5.0 2.5.1 2.5.10 2.5.11 2.5.12 2.5.13 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.2 2.6.3 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.8.0 2.8.1 2.9.0 2.9.1 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.10.0 3.11.0 3.12.0 3.12.1 3.12.2 3.12.3 3.13.0 3.14.0 3.14.1 3.14.2 3.15.0 3.15.1 3.16.0 3.16.1 3.16.2 3.16.3 3.16.4 3.16.5 3.17.0 3.17.1 3.17.2 3.18.0 3.19.0 3.19.1 3.19.2 3.19.3 3.19.4 3.2.0 3.2.1 3.2.2 3.20.0 3.21.0 3.21.1 3.22.0 3.22.1 3.22.2 3.3.0 3.3.1 3.4.0 3.4.1 3.4.2 3.5.0 3.5.1 3.6.0 3.6.1 3.6.2 3.7.0 3.8.0 3.9.0 4.0.0 4.1.0 4.1.1 4.10.0 4.10.1 4.11.0 4.12.0 4.13.0 4.13.1 4.13.2 4.14.0 4.14.1 4.14.2 4.14.3 4.14.4 4.14.5 4.14.6 4.2.0 4.2.1 4.3.0 4.3.1 4.3.2 4.4.0 4.5.0 4.6.1 4.7.0 4.7.1 4.8.0 4.8.1 4.9.0 trunk 1.9.0 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.10.0 2.10.1 2.10.2 2.10.3 2.10.4 2.11.0 2.11.1 2.11.2 2.11.3 2.12.0 2.12.1 2.12.2 2.12.3 2.13.0 2.13.1 2.13.2 2.13.3 2.13.4 2.14.0 2.15.0 2.16.0 2.16.1 2.17.0 2.17.1 2.17.3 2.18.0 2.18.1 2.19.1 2.19.2 2.19.3 2.19.4 2.19.5 2.19.6 2.19.7 2.19.8 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.20.0 2.20.1 2.20.2 2.21.0 2.21.1 2.21.2 2.21.3 2.21.4 2.22.0 2.22.1 2.22.2 2.22.3 2.23.0 2.23.1 2.23.2 2.24.0 2.24.1 2.24.2 2.25.0 2.25.1 2.25.2 2.25.3 2.26.0 2.27.0 2.27.1 2.27.2 2.27.3 2.28.0 2.29.0 2.29.1 2.29.2
give / vendor / vendor-prefixed / stellarwp / validation / src / Rules / Currency.php
give / vendor / vendor-prefixed / stellarwp / validation / src / Rules Last commit date
Abstracts 1 year ago Boolean.php 1 year ago Currency.php 1 year ago DateTime.php 1 year ago Email.php 1 year ago Exclude.php 1 year ago ExcludeIf.php 1 year ago ExcludeUnless.php 1 year ago In.php 1 year ago InStrict.php 1 year ago Integer.php 1 year ago Max.php 1 year ago Min.php 1 year ago Nullable.php 1 year ago NullableIf.php 1 year ago NullableUnless.php 1 year ago Numeric.php 1 year ago Optional.php 1 year ago OptionalIf.php 1 year ago OptionalUnless.php 1 year ago Required.php 1 year ago Size.php 1 year ago
Currency.php
249 lines
1 <?php
2
3 declare(strict_types=1);
4
5 namespace Give\Vendors\StellarWP\Validation\Rules;
6
7 use Closure;
8 use Give\Vendors\StellarWP\Validation\Contracts\ValidatesOnFrontEnd;
9 use Give\Vendors\StellarWP\Validation\Contracts\ValidationRule;
10
11 class Currency implements ValidationRule, ValidatesOnFrontEnd
12 {
13
14 /**
15 * @inheritDoc
16 *
17 * @since 1.0.0
18 */
19 public static function id(): string
20 {
21 return 'currency';
22 }
23
24 /**
25 * @inheritDoc
26 *
27 * @since 1.0.0
28 */
29 public static function fromString(?string $options = null): ValidationRule
30 {
31 return new self();
32 }
33
34 /**
35 * @inheritDoc
36 *
37 * @since 1.0.0
38 */
39 public function serializeOption()
40 {
41 return null;
42 }
43
44 /**
45 * @inheritDoc
46 *
47 * @since 1.0.0
48 */
49 public function __invoke($value, Closure $fail, string $key, array $values)
50 {
51 if (!is_string($value) || !in_array(strtoupper($value), self::currencyCodes(), true)) {
52 $fail(sprintf(__('%s must be a valid currency', 'give'), '{field}'));
53 }
54 }
55
56 /**
57 * Returns the list of valid ISO 4217 currency codes.
58 *
59 * @unreleased Updated to match current ISO 4217 standard as of 2024.
60 *
61 * Major changes include:
62 * - Removed obsolete codes: BYR (→BYN), EEK (→EUR), GHC (→GHS), LVL (→EUR),
63 * LTL (→EUR), TRL (→TRY), VEF (→VES), ZWD (→ZWL)
64 * - Added 74+ missing current ISO 4217 codes including AED, AMD, AOA, BHD, etc.
65 * - Kept commonly used non-ISO codes: GGP, IMP, JEP, TVD
66 * - Total codes increased from 95 to 169 for better global coverage
67 *
68 * @see https://www.iso.org/iso-4217-currency-codes.html
69 *
70 * @since 1.0.0
71 *
72 * @return string[]
73 */
74 public static function currencyCodes(): array
75 {
76 static $codes = null;
77
78 if ($codes === null) {
79 $codes = [
80 "AED", // UAE Dirham
81 "AFN", // Afghan Afghani
82 "ALL", // Albanian Lek
83 "AMD", // Armenian Dram
84 "ANG", // Netherlands Antillean Guilder
85 "AOA", // Angolan Kwanza
86 "ARS", // Argentine Peso
87 "AUD", // Australian Dollar
88 "AWG", // Aruban Florin
89 "AZN", // Azerbaijani Manat
90 "BAM", // Bosnia and Herzegovina Convertible Mark
91 "BBD", // Barbados Dollar
92 "BDT", // Bangladeshi Taka
93 "BGN", // Bulgarian Lev
94 "BHD", // Bahraini Dinar
95 "BIF", // Burundian Franc
96 "BMD", // Bermudian Dollar
97 "BND", // Brunei Dollar
98 "BOB", // Bolivian Boliviano
99 "BRL", // Brazilian Real
100 "BSD", // Bahamian Dollar
101 "BTN", // Bhutanese Ngultrum
102 "BWP", // Botswanan Pula
103 "BYN", // Belarusian Ruble
104 "BZD", // Belize Dollar
105 "CAD", // Canadian Dollar
106 "CDF", // Congolese Franc
107 "CHF", // Swiss Franc
108 "CLP", // Chilean Peso
109 "CNY", // Chinese Yuan
110 "COP", // Colombian Peso
111 "CRC", // Costa Rican Colón
112 "CUP", // Cuban Peso
113 "CVE", // Cape Verdean Escudo
114 "CZK", // Czech Koruna
115 "DJF", // Djiboutian Franc
116 "DKK", // Danish Krone
117 "DOP", // Dominican Peso
118 "DZD", // Algerian Dinar
119 "EGP", // Egyptian Pound
120 "ERN", // Eritrean Nakfa
121 "ETB", // Ethiopian Birr
122 "EUR", // Euro
123 "FJD", // Fijian Dollar
124 "FKP", // Falkland Islands Pound
125 "GBP", // British Pound Sterling
126 "GEL", // Georgian Lari
127 "GGP", // Guernsey Pound (non-ISO but commonly used)
128 "GHS", // Ghanaian Cedi
129 "GIP", // Gibraltar Pound
130 "GMD", // Gambian Dalasi
131 "GNF", // Guinean Franc
132 "GTQ", // Guatemalan Quetzal
133 "GYD", // Guyanese Dollar
134 "HKD", // Hong Kong Dollar
135 "HNL", // Honduran Lempira
136 "HRK", // Croatian Kuna (replaced by EUR in 2023)
137 "HTG", // Haitian Gourde
138 "HUF", // Hungarian Forint
139 "IDR", // Indonesian Rupiah
140 "ILS", // Israeli New Shekel
141 "IMP", // Isle of Man Pound (non-ISO but commonly used)
142 "INR", // Indian Rupee
143 "IQD", // Iraqi Dinar
144 "IRR", // Iranian Rial
145 "ISK", // Icelandic Króna
146 "JEP", // Jersey Pound (non-ISO but commonly used)
147 "JMD", // Jamaican Dollar
148 "JOD", // Jordanian Dinar
149 "JPY", // Japanese Yen
150 "KES", // Kenyan Shilling
151 "KGS", // Kyrgyzstani Som
152 "KHR", // Cambodian Riel
153 "KMF", // Comorian Franc
154 "KPW", // North Korean Won
155 "KRW", // South Korean Won
156 "KWD", // Kuwaiti Dinar
157 "KYD", // Cayman Islands Dollar
158 "KZT", // Kazakhstani Tenge
159 "LAK", // Laotian Kip
160 "LBP", // Lebanese Pound
161 "LKR", // Sri Lankan Rupee
162 "LRD", // Liberian Dollar
163 "LSL", // Lesotho Loti
164 "LYD", // Libyan Dinar
165 "MAD", // Moroccan Dirham
166 "MDL", // Moldovan Leu
167 "MGA", // Malagasy Ariary
168 "MKD", // Macedonian Denar
169 "MMK", // Myanmar Kyat
170 "MNT", // Mongolian Tugrik
171 "MOP", // Macanese Pataca
172 "MRU", // Mauritanian Ouguiya
173 "MUR", // Mauritian Rupee
174 "MVR", // Maldivian Rufiyaa
175 "MWK", // Malawian Kwacha
176 "MXN", // Mexican Peso
177 "MYR", // Malaysian Ringgit
178 "MZN", // Mozambican Metical
179 "NAD", // Namibian Dollar
180 "NGN", // Nigerian Naira
181 "NIO", // Nicaraguan Córdoba
182 "NOK", // Norwegian Krone
183 "NPR", // Nepalese Rupee
184 "NZD", // New Zealand Dollar
185 "OMR", // Omani Rial
186 "PAB", // Panamanian Balboa
187 "PEN", // Peruvian Sol
188 "PGK", // Papua New Guinean Kina
189 "PHP", // Philippine Peso
190 "PKR", // Pakistani Rupee
191 "PLN", // Polish Zloty
192 "PYG", // Paraguayan Guaraní
193 "QAR", // Qatari Riyal
194 "RON", // Romanian Leu
195 "RSD", // Serbian Dinar
196 "RUB", // Russian Ruble
197 "RWF", // Rwandan Franc
198 "SAR", // Saudi Riyal
199 "SBD", // Solomon Islands Dollar
200 "SCR", // Seychellois Rupee
201 "SDG", // Sudanese Pound
202 "SEK", // Swedish Krona
203 "SGD", // Singapore Dollar
204 "SHP", // Saint Helena Pound
205 "SLE", // Sierra Leonean Leone (new)
206 "SLL", // Sierra Leonean Leone (old)
207 "SOS", // Somali Shilling
208 "SRD", // Surinamese Dollar
209 "SSP", // South Sudanese Pound
210 "STN", // São Tomé and Príncipe Dobra
211 "SVC", // Salvadoran Colón
212 "SYP", // Syrian Pound
213 "SZL", // Swazi Lilangeni
214 "THB", // Thai Baht
215 "TJS", // Tajikistani Somoni
216 "TMT", // Turkmenistani Manat
217 "TND", // Tunisian Dinar
218 "TOP", // Tongan Paʻanga
219 "TRY", // Turkish Lira
220 "TTD", // Trinidad and Tobago Dollar
221 "TVD", // Tuvaluan Dollar (non-ISO but used)
222 "TWD", // New Taiwan Dollar
223 "TZS", // Tanzanian Shilling
224 "UAH", // Ukrainian Hryvnia
225 "UGX", // Ugandan Shilling
226 "USD", // United States Dollar
227 "UYU", // Uruguayan Peso
228 "UZS", // Uzbekistani Som
229 "VED", // Venezuelan Bolívar Digital
230 "VES", // Venezuelan Bolívar Soberano
231 "VND", // Vietnamese Dong
232 "VUV", // Vanuatuan Vatu
233 "WST", // Samoan Tala
234 "XAF", // Central African CFA Franc
235 "XCD", // East Caribbean Dollar
236 "XDR", // Special Drawing Rights
237 "XOF", // West African CFA Franc
238 "XPF", // CFP Franc
239 "YER", // Yemeni Rial
240 "ZAR", // South African Rand
241 "ZMW", // Zambian Kwacha
242 "ZWL", // Zimbabwean Dollar
243 ];
244 }
245
246 return $codes;
247 }
248 }
249