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
|
|
|
declare(strict_types=1); |
13
|
|
|
|
14
|
|
|
namespace Respect\Validation\Rules\Locale; |
15
|
|
|
|
16
|
|
|
use Respect\Validation\Rules\AbstractSearcher; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Validates whether an input is subdivision code of Spain or not. |
20
|
|
|
* |
21
|
|
|
* ISO 3166-1 alpha-2: ES |
22
|
|
|
* |
23
|
|
|
* @see http://www.geonames.org/ES/administrative-division-spain.html |
24
|
|
|
* |
25
|
|
|
* @author Henrique Moody <[email protected]> |
26
|
|
|
*/ |
27
|
|
|
final class EsSubdivisionCode extends AbstractSearcher |
28
|
|
|
{ |
29
|
|
|
private const DATA = [ |
30
|
|
|
'A', // Alicante |
31
|
|
|
'AB', // Albacete |
32
|
|
|
'AL', // Almería |
33
|
|
|
'AN', // Comunidad Autónoma de Andalucía |
34
|
|
|
'AR', // Comunidad Autónoma de Aragón |
35
|
|
|
'AS', // Comunidad Autónoma del Principado de Asturias |
36
|
|
|
'AV', // Ávila |
37
|
|
|
'B', // Barcelona |
38
|
|
|
'BA', // Badajoz |
39
|
|
|
'BI', // Vizcaya |
40
|
|
|
'BU', // Burgos |
41
|
|
|
'C', // A Coruña |
42
|
|
|
'CA', // Cádiz |
43
|
|
|
'CB', // Comunidad Autónoma de Cantabria |
44
|
|
|
'CC', // Cáceres |
45
|
|
|
'CE', // Ceuta |
46
|
|
|
'CL', // Comunidad Autónoma de Castilla y León |
47
|
|
|
'CM', // Comunidad Autónoma de Castilla-La Mancha |
48
|
|
|
'CN', // Comunidad Autónoma de Canarias |
49
|
|
|
'CO', // Córdoba |
50
|
|
|
'CR', // Ciudad Real |
51
|
|
|
'CS', // Castellón |
52
|
|
|
'CT', // Catalunya |
53
|
|
|
'CU', // Cuenca |
54
|
|
|
'EX', // Comunidad Autónoma de Extremadura |
55
|
|
|
'GA', // Comunidad Autónoma de Galicia |
56
|
|
|
'GC', // Las Palmas |
57
|
|
|
'GI', // Girona |
58
|
|
|
'GR', // Granada |
59
|
|
|
'GU', // Guadalajara |
60
|
|
|
'H', // Huelva |
61
|
|
|
'HU', // Huesca |
62
|
|
|
'IB', // Comunidad Autónoma de las Islas Baleares |
63
|
|
|
'J', // Jaén |
64
|
|
|
'L', // Lleida |
65
|
|
|
'LE', // León |
66
|
|
|
'LO', // La Rioja |
67
|
|
|
'LU', // Lugo |
68
|
|
|
'M', // Madrid |
69
|
|
|
'MA', // Málaga |
70
|
|
|
'MC', // Comunidad Autónoma de la Región de Murcia |
71
|
|
|
'MD', // Comunidad de Madrid |
72
|
|
|
'ML', // Melilla |
73
|
|
|
'MU', // Murcia |
74
|
|
|
'NA', // Navarra |
75
|
|
|
'NC', // Comunidad Foral de Navarra |
76
|
|
|
'O', // Asturias |
77
|
|
|
'OR', // Ourense |
78
|
|
|
'P', // Palencia |
79
|
|
|
'PM', // Baleares |
80
|
|
|
'PO', // Pontevedra |
81
|
|
|
'PV', // Euskal Autonomia Erkidegoa |
82
|
|
|
'RI', // Comunidad Autónoma de La Rioja |
83
|
|
|
'S', // Cantabria |
84
|
|
|
'SA', // Salamanca |
85
|
|
|
'SE', // Sevilla |
86
|
|
|
'SG', // Segovia |
87
|
|
|
'SO', // Soria |
88
|
|
|
'SS', // Guipúzcoa |
89
|
|
|
'T', // Tarragona |
90
|
|
|
'TE', // Teruel |
91
|
|
|
'TF', // Santa Cruz de Tenerife |
92
|
|
|
'TO', // Toledo |
93
|
|
|
'V', // Valencia |
94
|
|
|
'VA', // Valladolid |
95
|
|
|
'VC', // Comunidad Valenciana |
96
|
|
|
'VI', // Álava |
97
|
|
|
'Z', // Zaragoza |
98
|
|
|
'ZA', // Zamora |
99
|
|
|
]; |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* {@inheritdoc} |
103
|
|
|
*/ |
104
|
|
|
protected function getDataSource(): array |
105
|
|
|
{ |
106
|
|
|
return self::DATA; |
107
|
|
|
} |
108
|
|
|
} |
109
|
|
|
|