1 | <?php |
||
4 | class Counties { |
||
5 | /** |
||
6 | * An array of the counties with ID defined for backwards compatibility and incase of any future changes so new addition don't change existing numbers |
||
7 | * @var array An array of all of the UK counties |
||
8 | */ |
||
9 | protected static $counties = array( |
||
10 | // England |
||
11 | 1 => 'Bedfordshire', |
||
12 | 2 => 'Berkshire', |
||
13 | 3 => 'Bristol', |
||
14 | 4 => 'Buckinghamshire', |
||
15 | 5 => 'Cambridgeshire', |
||
16 | 6 => 'Cheshire', |
||
17 | 7 => 'City of London', |
||
18 | 8 => 'Cornwall', |
||
19 | 9 => 'Cumbria', |
||
20 | 10 => 'Derbyshire', |
||
21 | 11 => 'Devon', |
||
22 | 12 => 'Dorset', |
||
23 | 13 => 'Durham', |
||
24 | 14 => 'East Riding of Yorkshire', |
||
25 | 15 => 'East Sussex', |
||
26 | 16 => 'Essex', |
||
27 | 17 => 'Gloucestershire', |
||
28 | 18 => 'Greater London', |
||
29 | 19 => 'Greater Manchester', |
||
30 | 20 => 'Hampshire', |
||
31 | 21 => 'Herefordshire', |
||
32 | 22 => 'Hertfordshire', |
||
33 | 23 => 'Isle of Wight', |
||
34 | 24 => 'Kent', |
||
35 | 25 => 'Lancashire', |
||
36 | 26 => 'Leicestershire', |
||
37 | 27 => 'Lincolnshire', |
||
38 | 28 => 'Merseyside', |
||
39 | 29 => 'Norfolk', |
||
40 | 30 => 'North Yorkshire', |
||
41 | 31 => 'Northamptonshire', |
||
42 | 32 => 'Northumberland', |
||
43 | 33 => 'Nottinghamshire', |
||
44 | 34 => 'Oxfordshire', |
||
45 | 35 => 'Rutland', |
||
46 | 36 => 'Shropshire', |
||
47 | 37 => 'Somerset', |
||
48 | 38 => 'South Yorkshire', |
||
49 | 39 => 'Staffordshire', |
||
50 | 40 => 'Suffolk', |
||
51 | 41 => 'Surrey', |
||
52 | 42 => 'Tyne and Wear', |
||
53 | 43 => 'Warwickshire', |
||
54 | 44 => 'West Midlands', |
||
55 | 45 => 'West Sussex', |
||
56 | 46 => 'West Yorkshire', |
||
57 | 47 => 'Wiltshire', |
||
58 | 48 => 'Worcestershire', |
||
59 | |||
60 | // Scotland |
||
61 | 60 => 'Aberdeenshire', |
||
62 | 61 => 'Angus', |
||
63 | 62 => 'Argyll', |
||
64 | 63 => 'Ayrshire', |
||
65 | 64 => 'Banffshire', |
||
66 | 65 => 'Berwickshire', |
||
67 | 66 => 'Bute', |
||
68 | 67 => 'Caithness', |
||
69 | 68 => 'Clackmannanshire', |
||
70 | 69 => 'Cromartyshire', |
||
71 | 70 => 'Dumfriesshire', |
||
72 | 71 => 'Dunbartonshire', |
||
73 | 72 => 'East Lothian', |
||
74 | 73 => 'City of Edinburgh', |
||
75 | 74 => 'Fife', |
||
76 | 75 => 'Inverness-shire', |
||
77 | 76 => 'Kincardineshire', |
||
78 | 77 => 'Kinross-shire', |
||
79 | 78 => 'Kirkcudbrightshire', |
||
80 | 79 => 'Lanarkshire', |
||
81 | 80 => 'Midlothian', |
||
82 | 81 => 'Moray', |
||
83 | 82 => 'Nairnshire', |
||
84 | 83 => 'Orkney', |
||
85 | 84 => 'Peeblesshire', |
||
86 | 85 => 'Perthshire', |
||
87 | 86 => 'Renfrewshire', |
||
88 | 87 => 'Ross-shire', |
||
89 | 88 => 'Roxburghshire', |
||
90 | 89 => 'Selkirkshire', |
||
91 | 90 => 'Shetland', |
||
92 | 91 => 'Stirlingshire', |
||
93 | 92 => 'Sutherland', |
||
94 | 93 => 'West Lothian', |
||
95 | 94 => 'Wigtownshire', |
||
96 | |||
97 | // Wales |
||
98 | 110 => 'Blaenau Gwent', |
||
99 | 111 => 'Bridgend', |
||
100 | 112 => 'Caerphilly', |
||
101 | 113 => 'Cardiff', |
||
102 | 114 => 'Carmarthenshire', |
||
103 | 115 => 'Ceredigion', |
||
104 | 116 => 'Conwy', |
||
105 | 117 => 'Denbighshire', |
||
106 | 118 => 'Flintshire', |
||
107 | 119 => 'Gwynedd', |
||
108 | 120 => 'Isle of Anglesey', |
||
109 | 121 => 'Merthyr Tydfil', |
||
110 | 122 => 'Monmouthshire', |
||
111 | 123 => 'Neath Port Talbot', |
||
112 | 124 => 'Newport', |
||
113 | 125 => 'Pembrokeshire', |
||
114 | 126 => 'Powys', |
||
115 | 127 => 'Rhondda Cynon Taf', |
||
116 | 128 => 'Swansea', |
||
117 | 129 => 'Torfaen', |
||
118 | 130 => 'Vale of Glamorgan', |
||
119 | 131 => 'Wrexham', |
||
120 | |||
121 | // Northern Ireland |
||
122 | 150 => 'Antrim', |
||
123 | 151 => 'Armagh', |
||
124 | 152 => 'Down', |
||
125 | 153 => 'Fermanagh', |
||
126 | 154 => 'Londonderry', |
||
127 | 155 => 'Tyrone', |
||
128 | ); |
||
129 | |||
130 | /** |
||
131 | * Get the counties in their current order |
||
132 | * @return array This will be the list of counties |
||
133 | */ |
||
134 | 1 | public static function getCounties(){ |
|
137 | |||
138 | /** |
||
139 | * Return the counties listed in alphabetical order |
||
140 | * @return array This will be the list of counties |
||
141 | */ |
||
142 | 1 | public static function getCountiesByName(){ |
|
146 | |||
147 | /** |
||
148 | * Returns the total number of counties |
||
149 | * @return int The number of counties |
||
150 | */ |
||
151 | 1 | public static function getNumberOfCounties(){ |
|
154 | |||
155 | /** |
||
156 | * Returns the id of a given county name |
||
157 | * @param string $county This should be the county name you wish to find the id for |
||
158 | * @return int|false Returns the id of the given county name if it exists else returns false |
||
159 | */ |
||
160 | 1 | public static function getCountyID($county){ |
|
167 | |||
168 | /** |
||
169 | * Returns the county name of a given county id |
||
170 | * @param int $id This should be the id of the county you wish to know the name of |
||
171 | * @return string|false Will return the county name of the id if it exists else will return false |
||
172 | */ |
||
173 | 1 | public static function getCountyName($id){ |
|
179 | } |
||
180 |