# Source for file Country.php

Documentation is available at Country.php

1. <?php
2. /*
3. * $Id: Country.php 1080 2007-02-10 18:17:08Z romanb $
4. *
5. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
6. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
7. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
8. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
9. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
10. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
11. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
12. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
13. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
14. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
15. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
16. *
17. * This software consists of voluntary contributions made by many individuals
18. * and is licensed under the LGPL. For more information, see
19. * <http://www.phpdoctrine.com>.
20. */
22. /**
23. * Doctrine_Validator_Country
24. *
25. * @package Doctrine
26. * @category Object Relational Mapping
27. * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
28. * @link www.phpdoctrine.com
29. * @since 1.0
30. * @version $Revision: 1080 $
31. * @author Konsta Vesterinen <kvesteri@cc.hut.fi>
32. */
33. class Doctrine_Validator_Country
34. {
35. private static $countries = array(
36. 'ad' => 'Andorra',
37. 'ae' => 'United Arab Emirates',
38. 'af' => 'Afghanistan',
39. 'ag' => 'Antigua and Barbuda',
40. 'ai' => 'Anguilla',
41. 'al' => 'Albania',
42. 'am' => 'Armenia',
43. 'an' => 'Netherlands Antilles',
44. 'ao' => 'Angola',
45. 'aq' => 'Antarctica',
46. 'ar' => 'Argentina',
47. 'as' => 'American Samoa',
48. 'at' => 'Austria',
49. 'au' => 'Australia',
50. 'aw' => 'Aruba',
51. 'az' => 'Azerbaijan',
52. 'ba' => 'Bosnia Hercegovina',
53. 'bb' => 'Barbados',
54. 'bd' => 'Bangladesh',
55. 'be' => 'Belgium',
56. 'bf' => 'Burkina Faso',
57. 'bg' => 'Bulgaria',
58. 'bh' => 'Bahrain',
59. 'bi' => 'Burundi',
60. 'bj' => 'Benin',
61. 'bm' => 'Bermuda',
62. 'bn' => 'Brunei Darussalam',
63. 'bo' => 'Bolivia',
64. 'br' => 'Brazil',
65. 'bs' => 'Bahamas',
66. 'bt' => 'Bhutan',
67. 'bv' => 'Bouvet Island',
68. 'bw' => 'Botswana',
69. 'by' => 'Belarus (Byelorussia)',
70. 'bz' => 'Belize',
71. 'ca' => 'Canada',
72. 'cc' => 'Cocos Islands',
73. 'cd' => 'Congo, The Democratic Republic of the',
74. 'cf' => 'Central African Republic',
75. 'cg' => 'Congo',
76. 'ch' => 'Switzerland',
77. 'ci' => 'Ivory Coast',
78. 'ck' => 'Cook Islands',
79. 'cl' => 'Chile',
80. 'cm' => 'Cameroon',
81. 'cn' => 'China',
82. 'co' => 'Colombia',
83. 'cr' => 'Costa Rica',
84. 'cs' => 'Czechoslovakia',
85. 'cu' => 'Cuba',
86. 'cv' => 'Cape Verde',
87. 'cx' => 'Christmas Island',
88. 'cy' => 'Cyprus',
89. 'cz' => 'Czech Republic',
90. 'de' => 'Germany',
91. 'dj' => 'Djibouti',
92. 'dk' => 'Denmark',
93. 'dm' => 'Dominica',
94. 'do' => 'Dominican Republic',
95. 'dz' => 'Algeria',
96. 'ec' => 'Ecuador',
97. 'ee' => 'Estonia',
98. 'eg' => 'Egypt',
99. 'eh' => 'Western Sahara',
100. 'er' => 'Eritrea',
101. 'es' => 'Spain',
102. 'et' => 'Ethiopia',
103. 'fi' => 'Finland',
104. 'fj' => 'Fiji',
105. 'fk' => 'Falkland Islands',
106. 'fm' => 'Micronesia',
107. 'fo' => 'Faroe Islands',
108. 'fr' => 'France',
109. 'fx' => 'France, Metropolitan FX',
110. 'ga' => 'Gabon',
111. 'gb' => 'United Kingdom (Great Britain)',
112. 'gd' => 'Grenada',
113. 'ge' => 'Georgia',
114. 'gf' => 'French Guiana',
115. 'gh' => 'Ghana',
116. 'gi' => 'Gibraltar',
117. 'gl' => 'Greenland',
118. 'gm' => 'Gambia',
119. 'gn' => 'Guinea',
120. 'gp' => 'Guadeloupe',
121. 'gq' => 'Equatorial Guinea',
122. 'gr' => 'Greece',
123. 'gs' => 'South Georgia and the South Sandwich Islands',
124. 'gt' => 'Guatemala',
125. 'gu' => 'Guam',
126. 'gw' => 'Guinea-bissau',
127. 'gy' => 'Guyana',
128. 'hk' => 'Hong Kong',
129. 'hm' => 'Heard and McDonald Islands',
130. 'hn' => 'Honduras',
131. 'hr' => 'Croatia',
132. 'ht' => 'Haiti',
133. 'hu' => 'Hungary',
134. 'id' => 'Indonesia',
135. 'ie' => 'Ireland',
136. 'il' => 'Israel',
137. 'in' => 'India',
138. 'io' => 'British Indian Ocean Territory',
139. 'iq' => 'Iraq',
140. 'ir' => 'Iran',
141. 'is' => 'Iceland',
142. 'it' => 'Italy',
143. 'jm' => 'Jamaica',
144. 'jo' => 'Jordan',
145. 'jp' => 'Japan',
146. 'ke' => 'Kenya',
147. 'kg' => 'Kyrgyzstan',
148. 'kh' => 'Cambodia',
149. 'ki' => 'Kiribati',
150. 'km' => 'Comoros',
151. 'kn' => 'Saint Kitts and Nevis',
152. 'kp' => 'North Korea',
153. 'kr' => 'South Korea',
154. 'kw' => 'Kuwait',
155. 'ky' => 'Cayman Islands',
156. 'kz' => 'Kazakhstan',
157. 'la' => 'Laos',
158. 'lb' => 'Lebanon',
159. 'lc' => 'Saint Lucia',
160. 'li' => 'Lichtenstein',
161. 'lk' => 'Sri Lanka',
162. 'lr' => 'Liberia',
163. 'ls' => 'Lesotho',
164. 'lt' => 'Lithuania',
165. 'lu' => 'Luxembourg',
166. 'lv' => 'Latvia',
167. 'ly' => 'Libya',
168. 'ma' => 'Morocco',
169. 'mc' => 'Monaco',
170. 'md' => 'Moldova Republic',
171. 'mg' => 'Madagascar',
172. 'mh' => 'Marshall Islands',
173. 'mk' => 'Macedonia, The Former Yugoslav Republic of',
174. 'ml' => 'Mali',
175. 'mm' => 'Myanmar',
176. 'mn' => 'Mongolia',
177. 'mo' => 'Macau',
178. 'mp' => 'Northern Mariana Islands',
179. 'mq' => 'Martinique',
180. 'mr' => 'Mauritania',
181. 'ms' => 'Montserrat',
182. 'mt' => 'Malta',
183. 'mu' => 'Mauritius',
184. 'mv' => 'Maldives',
185. 'mw' => 'Malawi',
186. 'mx' => 'Mexico',
187. 'my' => 'Malaysia',
188. 'mz' => 'Mozambique',
189. 'na' => 'Namibia',
190. 'nc' => 'New Caledonia',
191. 'ne' => 'Niger',
192. 'nf' => 'Norfolk Island',
193. 'ng' => 'Nigeria',
194. 'ni' => 'Nicaragua',
195. 'nl' => 'Netherlands',
196. 'no' => 'Norway',
197. 'np' => 'Nepal',
198. 'nr' => 'Nauru',
199. 'nt' => 'Neutral Zone',
200. 'nu' => 'Niue',
201. 'nz' => 'New Zealand',
202. 'om' => 'Oman',
203. 'pa' => 'Panama',
204. 'pe' => 'Peru',
205. 'pf' => 'French Polynesia',
206. 'pg' => 'Papua New Guinea',
207. 'ph' => 'Philippines',
208. 'pk' => 'Pakistan',
209. 'pl' => 'Poland',
210. 'pm' => 'St. Pierre and Miquelon',
211. 'pn' => 'Pitcairn',
212. 'pr' => 'Puerto Rico',
213. 'pt' => 'Portugal',
214. 'pw' => 'Palau',
215. 'py' => 'Paraguay',
216. 'qa' => 'Qatar',
217. 're' => 'Reunion',
218. 'ro' => 'Romania',
219. 'ru' => 'Russia',
220. 'rw' => 'Rwanda',
221. 'sa' => 'Saudi Arabia',
222. 'sb' => 'Solomon Islands',
223. 'sc' => 'Seychelles',
224. 'sd' => 'Sudan',
225. 'se' => 'Sweden',
226. 'sg' => 'Singapore',
227. 'sh' => 'St. Helena',
228. 'si' => 'Slovenia',
229. 'sj' => 'Svalbard and Jan Mayen Islands',
230. 'sk' => 'Slovakia (Slovak Republic)',
231. 'sl' => 'Sierra Leone',
232. 'sm' => 'San Marino',
233. 'sn' => 'Senegal',
234. 'so' => 'Somalia',
235. 'sr' => 'Suriname',
236. 'st' => 'Sao Tome and Principe',
237. 'sv' => 'El Salvador',
238. 'sy' => 'Syria',
239. 'sz' => 'Swaziland',
240. 'tc' => 'Turks and Caicos Islands',
241. 'td' => 'Chad',
242. 'tf' => 'French Southern Territories',
243. 'tg' => 'Togo',
244. 'th' => 'Thailand',
245. 'tj' => 'Tajikistan',
246. 'tk' => 'Tokelau',
247. 'tm' => 'Turkmenistan',
248. 'tn' => 'Tunisia',
249. 'to' => 'Tonga',
250. 'tp' => 'East Timor',
251. 'tr' => 'Turkey',
252. 'tt' => 'Trinidad, Tobago',
253. 'tv' => 'Tuvalu',
254. 'tw' => 'Taiwan',
255. 'tz' => 'Tanzania',
256. 'ua' => 'Ukraine',
257. 'ug' => 'Uganda',
258. 'uk' => 'United Kingdom',
259. 'um' => 'United States Minor Islands',
260. 'us' => 'United States of America',
261. 'uy' => 'Uruguay',
262. 'uz' => 'Uzbekistan',
263. 'va' => 'Vatican City',
264. 'vc' => 'Saint Vincent, Grenadines',
265. 've' => 'Venezuela',
266. 'vg' => 'Virgin Islands (British)',
267. 'vi' => 'Virgin Islands (USA)',
268. 'vn' => 'Viet Nam',
269. 'vu' => 'Vanuatu',
270. 'wf' => 'Wallis and Futuna Islands',
271. 'ws' => 'Samoa',
272. 'ye' => 'Yemen',
273. 'yt' => 'Mayotte',
274. 'yu' => 'Yugoslavia',
275. 'za' => 'South Africa',
276. 'zm' => 'Zambia',
277. 'zr' => 'Zaire',
278. 'zw' => 'Zimbabwe');
279. /**
280. * @return array
281. */
282. public static function getCountries()
283. {
284. return self::$countries;
285. }
286. /**
287. * @param Doctrine_Record $record
288. * @param string $key
289. * @param mixed $value
290. * @param string $args
291. * @return boolean
292. */
293. public function validate(Doctrine_Record $record, $key, $value, $args)
294. {
295. $value = strtolower($value);
296. return isset(self::$countries[$value]);
297. }
299. }