Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Completed
Push — 2.0 ( e6a123...4184ab )
by Henrique
03:41
created

CurrencyCode::validate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 1
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
3
/*
4
 * This file is part of Respect/Validation.
5
 *
6
 * (c) Alexandre Gomes Gaigalas <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the "LICENSE.md"
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Respect\Validation\Rules;
13
14
/**
15
 * Validates currency codes in ISO 4217.
16
 */
17
class CurrencyCode extends AbstractRule
18
{
19
    /**
20
     * @link http://www.currency-iso.org/en/home/tables/table-a1.html
21
     *
22
     * @var array
23
     */
24
    private $currencyCodes = [
25
        'AED', // UAE Dirham
26
        'AFN', // Afghani
27
        'ALL', // Lek
28
        'AMD', // Armenian Dram
29
        'ANG', // Netherlands Antillean Guilder
30
        'AOA', // Kwanza
31
        'ARS', // Argentine Peso
32
        'AUD', // Australian Dollar
33
        'AWG', // Aruban Florin
34
        'AZN', // Azerbaijanian Manat
35
        'BAM', // Convertible Mark
36
        'BBD', // Barbados Dollar
37
        'BDT', // Taka
38
        'BGN', // Bulgarian Lev
39
        'BHD', // Bahraini Dinar
40
        'BIF', // Burundi Franc
41
        'BMD', // Bermudian Dollar
42
        'BND', // Brunei Dollar
43
        'BOB', // Boliviano
44
        'BOV', // Mvdol
45
        'BRL', // Brazilian Real
46
        'BSD', // Bahamian Dollar
47
        'BTN', // Ngultrum
48
        'BWP', // Pula
49
        'BYR', // Belarussian Ruble
50
        'BZD', // Belize Dollar
51
        'CAD', // Canadian Dollar
52
        'CDF', // Congolese Franc
53
        'CHE', // WIR Euro
54
        'CHF', // Swiss Franc
55
        'CHW', // WIR Franc
56
        'CLF', // Unidad de Fomento
57
        'CLP', // Chilean Peso
58
        'CNY', // Yuan Renminbi
59
        'COP', // Colombian Peso
60
        'COU', // Unidad de Valor Real
61
        'CRC', // Costa Rican Colon
62
        'CUC', // Peso Convertible
63
        'CUP', // Cuban Peso
64
        'CVE', // Cabo Verde Escudo
65
        'CZK', // Czech Koruna
66
        'DJF', // Djibouti Franc
67
        'DKK', // Danish Krone
68
        'DOP', // Dominican Peso
69
        'DZD', // Algerian Dinar
70
        'EGP', // Egyptian Pound
71
        'ERN', // Nakfa
72
        'ETB', // Ethiopian Birr
73
        'EUR', // Euro
74
        'FJD', // Fiji Dollar
75
        'FKP', // Falkland Islands Pound
76
        'GBP', // Pound Sterling
77
        'GEL', // Lari
78
        'GHS', // Ghana Cedi
79
        'GIP', // Gibraltar Pound
80
        'GMD', // Dalasi
81
        'GNF', // Guinea Franc
82
        'GTQ', // Quetzal
83
        'GYD', // Guyana Dollar
84
        'HKD', // Hong Kong Dollar
85
        'HNL', // Lempira
86
        'HRK', // Kuna
87
        'HTG', // Gourde
88
        'HUF', // Forint
89
        'IDR', // Rupiah
90
        'ILS', // New Israeli Sheqel
91
        'INR', // Indian Rupee
92
        'IQD', // Iraqi Dinar
93
        'IRR', // Iranian Rial
94
        'ISK', // Iceland Krona
95
        'JMD', // Jamaican Dollar
96
        'JOD', // Jordanian Dinar
97
        'JPY', // Yen
98
        'KES', // Kenyan Shilling
99
        'KGS', // Som
100
        'KHR', // Riel
101
        'KMF', // Comoro Franc
102
        'KPW', // North Korean Won
103
        'KRW', // Won
104
        'KWD', // Kuwaiti Dinar
105
        'KYD', // Cayman Islands Dollar
106
        'KZT', // Tenge
107
        'LAK', // Kip
108
        'LBP', // Lebanese Pound
109
        'LKR', // Sri Lanka Rupee
110
        'LRD', // Liberian Dollar
111
        'LSL', // Loti
112
        'LYD', // Libyan Dinar
113
        'MAD', // Moroccan Dirham
114
        'MDL', // Moldovan Leu
115
        'MGA', // Malagasy Ariary
116
        'MKD', // Denar
117
        'MMK', // Kyat
118
        'MNT', // Tugrik
119
        'MOP', // Pataca
120
        'MRO', // Ouguiya
121
        'MUR', // Mauritius Rupee
122
        'MVR', // Rufiyaa
123
        'MWK', // Kwacha
124
        'MXN', // Mexican Peso
125
        'MXV', // Mexican Unidad de Inversion (UDI)
126
        'MYR', // Malaysian Ringgit
127
        'MZN', // Mozambique Metical
128
        'NAD', // Namibia Dollar
129
        'NGN', // Naira
130
        'NIO', // Cordoba Oro
131
        'NOK', // Norwegian Krone
132
        'NPR', // Nepalese Rupee
133
        'NZD', // New Zealand Dollar
134
        'OMR', // Rial Omani
135
        'PAB', // Balboa
136
        'PEN', // Nuevo Sol
137
        'PGK', // Kina
138
        'PHP', // Philippine Peso
139
        'PKR', // Pakistan Rupee
140
        'PLN', // Zloty
141
        'PYG', // Guarani
142
        'QAR', // Qatari Rial
143
        'RON', // Romanian Leu
144
        'RSD', // Serbian Dinar
145
        'RUB', // Russian Ruble
146
        'RWF', // Rwanda Franc
147
        'SAR', // Saudi Riyal
148
        'SBD', // Solomon Islands Dollar
149
        'SCR', // Seychelles Rupee
150
        'SDG', // Sudanese Pound
151
        'SEK', // Swedish Krona
152
        'SGD', // Singapore Dollar
153
        'SHP', // Saint Helena Pound
154
        'SLL', // Leone
155
        'SOS', // Somali Shilling
156
        'SRD', // Surinam Dollar
157
        'SSP', // South Sudanese Pound
158
        'STD', // Dobra
159
        'SVC', // El Salvador Colon
160
        'SYP', // Syrian Pound
161
        'SZL', // Lilangeni
162
        'THB', // Baht
163
        'TJS', // Somoni
164
        'TMT', // Turkmenistan New Manat
165
        'TND', // Tunisian Dinar
166
        'TOP', // Pa’anga
167
        'TRY', // Turkish Lira
168
        'TTD', // Trinidad and Tobago Dollar
169
        'TWD', // New Taiwan Dollar
170
        'TZS', // Tanzanian Shilling
171
        'UAH', // Hryvnia
172
        'UGX', // Uganda Shilling
173
        'USD', // US Dollar
174
        'USN', // US Dollar (Next day)
175
        'UYI', // Uruguay Peso en Unidades Indexadas (URUIURUI)
176
        'UYU', // Peso Uruguayo
177
        'UZS', // Uzbekistan Sum
178
        'VEF', // Bolivar
179
        'VND', // Dong
180
        'VUV', // Vatu
181
        'WST', // Tala
182
        'XAF', // CFA Franc BEAC
183
        'XAG', // Silver
184
        'XAU', // Gold
185
        'XBA', // Bond Markets Unit European Composite Unit (EURCO)
186
        'XBB', // Bond Markets Unit European Monetary Unit (E.M.U.-6)
187
        'XBC', // Bond Markets Unit European Unit of Account 9 (E.U.A.-9)
188
        'XBD', // Bond Markets Unit European Unit of Account 17 (E.U.A.-17)
189
        'XCD', // East Caribbean Dollar
190
        'XDR', // SDR (Special Drawing Right)
191
        'XOF', // CFA Franc BCEAO
192
        'XPD', // Palladium
193
        'XPF', // CFP Franc
194
        'XPT', // Platinum
195
        'XSU', // Sucre
196
        'XTS', // Codes specifically reserved for testing purposes
197
        'XUA', // ADB Unit of Account
198
        'XXX', // The codes assigned for transactions where no currency is involved
199
        'YER', // Yemeni Rial
200
        'ZAR', // Rand
201
        'ZMW', // Zambian Kwacha
202
        'ZWL', // Zimbabwe Dollar
203
    ];
204
205
    public function validate($input)
206
    {
207
        return in_array(mb_strtoupper($input), $this->currencyCodes, true);
208
    }
209
}
210