Skip to content

Commit

Permalink
initialize
Browse files Browse the repository at this point in the history
  • Loading branch information
lichunqiang committed Nov 2, 2015
0 parents commit a5ae95c
Show file tree
Hide file tree
Showing 4 changed files with 322 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# editorconfig.org
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8

[*.php]
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.{js,twig,css,scss,html}]
indent_style = space
indent_size = 2

[{Gruntfile.js,bower.json,composer.json,package.json}]
indent_style = space
indent_size = 2

[*.md]
trim_trailing_whitespace = false
14 changes: 14 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "light/countries",
"description": "Country list",
"type": "library",
"license": "MIT",
"authors": [
{
"name": "lichunqiang",
"email": "[email protected]"
}
],
"minimum-stability": "dev",
"require": {}
}
255 changes: 255 additions & 0 deletions data/countries.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,255 @@
<?php
return [
['full' => 'Abkhazia', 'short' => 'AB', 'currency' => 'RUB'],
['full' => 'Afghanistan', 'short' => 'AF', 'currency' => 'AFN'],
['full' => 'Åland Islands', 'short' => 'AX', 'currency' => 'EUR'],
['full' => 'Albania', 'short' => 'AL', 'currency' => 'ALL'],
['full' => 'Algeria', 'short' => 'DZ', 'currency' => 'DZD'],
['full' => 'American Samoa', 'short' => 'AS', 'currency' => 'USD'],
['full' => 'Andorra', 'short' => 'AD', 'currency' => 'EUR'],
['full' => 'Angola', 'short' => 'AO', 'currency' => 'AOA'],
['full' => 'Anguilla', 'short' => 'AI', 'currency' => 'XCD'],
['full' => 'Antarctica', 'short' => 'AQ', 'currency' => ''],
['full' => 'Antigua and Barbuda', 'short' => 'AG', 'currency' => 'XCD'],
['full' => 'Argentina', 'short' => 'AR', 'currency' => 'ARS'],
['full' => 'Armenia', 'short' => 'AM', 'currency' => 'AMD'],
['full' => 'Aruba', 'short' => 'AW', 'currency' => 'AWG'],
['full' => 'Australia', 'short' => 'AU', 'currency' => 'AUD'],
['full' => 'Austria', 'short' => 'AT', 'currency' => 'EUR'],
['full' => 'Azerbaijan', 'short' => 'AZ', 'currency' => 'AZN'],
['full' => 'Bahamas', 'short' => 'BS', 'currency' => 'BSD'],
['full' => 'Bahrain', 'short' => 'BH', 'currency' => 'BHD'],
['full' => 'Bangladesh', 'short' => 'BD', 'currency' => 'BDT'],
['full' => 'Barbados', 'short' => 'BB', 'currency' => 'BBD'],
['full' => 'Belarus', 'short' => 'BY', 'currency' => 'BYR'],
['full' => 'Belgium', 'short' => 'BE', 'currency' => 'EUR'],
['full' => 'Belize', 'short' => 'BZ', 'currency' => 'BZD'],
['full' => 'Benin', 'short' => 'BJ', 'currency' => 'XOF'],
['full' => 'Bermuda', 'short' => 'BM', 'currency' => 'BMD'],
['full' => 'Bhutan', 'short' => 'BT', 'currency' => 'BTN'],
['full' => 'Bolivia', 'short' => 'BO', 'currency' => 'BOB'],
['full' => 'Bonaire', 'short' => 'BQ', 'currency' => 'USD'],
['full' => 'Bosnia and Herzegovina', 'short' => 'BA', 'currency' => 'BAM'],
['full' => 'Botswana', 'short' => 'BW', 'currency' => 'BWP'],
['full' => 'Bouvet Island', 'short' => 'BV', 'currency' => 'NOK'],
['full' => 'Brazil', 'short' => 'BR', 'currency' => 'BRL'],
['full' => 'British Indian Ocean Territory', 'short' => 'IO', 'currency' => 'USD'],
['full' => 'British Virgin Islands', 'short' => 'VG', 'currency' => 'USD'],
['full' => 'Brunei', 'short' => 'BN', 'currency' => 'BND'],
['full' => 'Bulgaria', 'short' => 'BG', 'currency' => 'BGN'],
['full' => 'Burkina Faso', 'short' => 'BF', 'currency' => 'XOF'],
['full' => 'Burundi', 'short' => 'BI', 'currency' => 'BIF'],
['full' => 'Cambodia', 'short' => 'KH', 'currency' => 'KHR'],
['full' => 'Cameroon', 'short' => 'CM', 'currency' => 'XAF'],
['full' => 'Canada', 'short' => 'CA', 'currency' => 'CAD'],
['full' => 'Cape Verde', 'short' => 'CV', 'currency' => 'CVE'],
['full' => 'Cayman Islands', 'short' => 'KY', 'currency' => 'KYD'],
['full' => 'Central African Republic', 'short' => 'CF', 'currency' => 'XAF'],
['full' => 'Chad', 'short' => 'TD', 'currency' => 'XAF'],
['full' => 'Chile', 'short' => 'CL', 'currency' => 'CLF'],
['full' => 'China', 'short' => 'CN', 'currency' => 'CNY'],
['full' => 'Christmas Island', 'short' => 'CX', 'currency' => 'AUD'],
['full' => 'Cocos (Keeling) Islands', 'short' => 'CC', 'currency' => 'AUD'],
['full' => 'Colombia', 'short' => 'CO', 'currency' => 'COP'],
['full' => 'Comoros', 'short' => 'KM', 'currency' => 'KMF'],
['full' => 'Republic of the Congo', 'short' => 'CG', 'currency' => 'XAF'],
['full' => 'DR Congo', 'short' => 'CD', 'currency' => 'CDF'],
['full' => 'Cook Islands', 'short' => 'CK', 'currency' => 'NZD'],
['full' => 'Costa Rica', 'short' => 'CR', 'currency' => 'CRC'],
['full' => 'Croatia', 'short' => 'HR', 'currency' => 'HRK'],
['full' => 'Cuba', 'short' => 'CU', 'currency' => 'CUC'],
['full' => 'Curaçao', 'short' => 'CW', 'currency' => 'ANG'],
['full' => 'Cyprus', 'short' => 'CY', 'currency' => 'EUR'],
['full' => 'Czech Republic', 'short' => 'CZ', 'currency' => 'CZK'],
['full' => 'Denmark', 'short' => 'DK', 'currency' => 'DKK'],
['full' => 'Djibouti', 'short' => 'DJ', 'currency' => 'DJF'],
['full' => 'Dominica', 'short' => 'DM', 'currency' => 'XCD'],
['full' => 'Dominican Republic', 'short' => 'DO', 'currency' => 'DOP'],
['full' => 'Ecuador', 'short' => 'EC', 'currency' => 'USD'],
['full' => 'Egypt', 'short' => 'EG', 'currency' => 'EGP'],
['full' => 'El Salvador', 'short' => 'SV', 'currency' => 'SVC'],
['full' => 'Equatorial Guinea', 'short' => 'GQ', 'currency' => 'XAF'],
['full' => 'Eritrea', 'short' => 'ER', 'currency' => 'ERN'],
['full' => 'Estonia', 'short' => 'EE', 'currency' => 'EUR'],
['full' => 'Ethiopia', 'short' => 'ET', 'currency' => 'ETB'],
['full' => 'Falkland Islands', 'short' => 'FK', 'currency' => 'FKP'],
['full' => 'Faroe Islands', 'short' => 'FO', 'currency' => 'DKK'],
['full' => 'Fiji', 'short' => 'FJ', 'currency' => 'FJD'],
['full' => 'Finland', 'short' => 'FI', 'currency' => 'EUR'],
['full' => 'France', 'short' => 'FR', 'currency' => 'EUR'],
['full' => 'French Guiana', 'short' => 'GF', 'currency' => 'EUR'],
['full' => 'French Polynesia', 'short' => 'PF', 'currency' => 'XPF'],
['full' => 'French Southern and Antarctic Lands', 'short' => 'TF', 'currency' => 'EUR'],
['full' => 'Gabon', 'short' => 'GA', 'currency' => 'XAF'],
['full' => 'Gambia', 'short' => 'GM', 'currency' => 'GMD'],
['full' => 'Georgia', 'short' => 'GE', 'currency' => 'GEL'],
['full' => 'Germany', 'short' => 'DE', 'currency' => 'EUR'],
['full' => 'Ghana', 'short' => 'GH', 'currency' => 'GHS'],
['full' => 'Gibraltar', 'short' => 'GI', 'currency' => 'GIP'],
['full' => 'Greece', 'short' => 'GR', 'currency' => 'EUR'],
['full' => 'Greenland', 'short' => 'GL', 'currency' => 'DKK'],
['full' => 'Grenada', 'short' => 'GD', 'currency' => 'XCD'],
['full' => 'Guadeloupe', 'short' => 'GP', 'currency' => 'EUR'],
['full' => 'Guam', 'short' => 'GU', 'currency' => 'USD'],
['full' => 'Guatemala', 'short' => 'GT', 'currency' => 'GTQ'],
['full' => 'Guernsey', 'short' => 'GG', 'currency' => 'GBP'],
['full' => 'Guinea', 'short' => 'GN', 'currency' => 'GNF'],
['full' => 'Guinea-Bissau', 'short' => 'GW', 'currency' => 'XOF'],
['full' => 'Guyana', 'short' => 'GY', 'currency' => 'GYD'],
['full' => 'Haiti', 'short' => 'HT', 'currency' => 'HTG'],
['full' => 'Heard Island and McDonald Islands', 'short' => 'HM', 'currency' => 'AUD'],
['full' => 'Vatican City', 'short' => 'VA', 'currency' => 'EUR'],
['full' => 'Honduras', 'short' => 'HN', 'currency' => 'HNL'],
['full' => 'Hong Kong', 'short' => 'HK', 'currency' => 'HKD'],
['full' => 'Hungary', 'short' => 'HU', 'currency' => 'HUF'],
['full' => 'Iceland', 'short' => 'IS', 'currency' => 'ISK'],
['full' => 'India', 'short' => 'IN', 'currency' => 'INR'],
['full' => 'Indonesia', 'short' => 'ID', 'currency' => 'IDR'],
['full' => 'Ivory Coast', 'short' => 'CI', 'currency' => 'XOF'],
['full' => 'Iran', 'short' => 'IR', 'currency' => 'IRR'],
['full' => 'Iraq', 'short' => 'IQ', 'currency' => 'IQD'],
['full' => 'Ireland', 'short' => 'IE', 'currency' => 'EUR'],
['full' => 'Isle of Man', 'short' => 'IM', 'currency' => 'GBP'],
['full' => 'Israel', 'short' => 'IL', 'currency' => 'ILS'],
['full' => 'Italy', 'short' => 'IT', 'currency' => 'EUR'],
['full' => 'Jamaica', 'short' => 'JM', 'currency' => 'JMD'],
['full' => 'Japan', 'short' => 'JP', 'currency' => 'JPY'],
['full' => 'Jersey', 'short' => 'JE', 'currency' => 'GBP'],
['full' => 'Jordan', 'short' => 'JO', 'currency' => 'JOD'],
['full' => 'Kazakhstan', 'short' => 'KZ', 'currency' => 'KZT'],
['full' => 'Kenya', 'short' => 'KE', 'currency' => 'KES'],
['full' => 'Kiribati', 'short' => 'KI', 'currency' => 'AUD'],
['full' => 'Kuwait', 'short' => 'KW', 'currency' => 'KWD'],
['full' => 'Kyrgyzstan', 'short' => 'KG', 'currency' => 'KGS'],
['full' => 'Laos', 'short' => 'LA', 'currency' => 'LAK'],
['full' => 'Latvia', 'short' => 'LV', 'currency' => 'EUR'],
['full' => 'Lebanon', 'short' => 'LB', 'currency' => 'LBP'],
['full' => 'Lesotho', 'short' => 'LS', 'currency' => 'LSL'],
['full' => 'Liberia', 'short' => 'LR', 'currency' => 'LRD'],
['full' => 'Libya', 'short' => 'LY', 'currency' => 'LYD'],
['full' => 'Liechtenstein', 'short' => 'LI', 'currency' => 'CHF'],
['full' => 'Lithuania', 'short' => 'LT', 'currency' => 'LTL'],
['full' => 'Luxembourg', 'short' => 'LU', 'currency' => 'EUR'],
['full' => 'Macau', 'short' => 'MO', 'currency' => 'MOP'],
['full' => 'Macedonia', 'short' => 'MK', 'currency' => 'MKD'],
['full' => 'Madagascar', 'short' => 'MG', 'currency' => 'MGA'],
['full' => 'Malawi', 'short' => 'MW', 'currency' => 'MWK'],
['full' => 'Malaysia', 'short' => 'MY', 'currency' => 'MYR'],
['full' => 'Maldives', 'short' => 'MV', 'currency' => 'MVR'],
['full' => 'Mali', 'short' => 'ML', 'currency' => 'XOF'],
['full' => 'Malta', 'short' => 'MT', 'currency' => 'EUR'],
['full' => 'Marshall Islands', 'short' => 'MH', 'currency' => 'USD'],
['full' => 'Martinique', 'short' => 'MQ', 'currency' => 'EUR'],
['full' => 'Mauritania', 'short' => 'MR', 'currency' => 'MRO'],
['full' => 'Mauritius', 'short' => 'MU', 'currency' => 'MUR'],
['full' => 'Mayotte', 'short' => 'YT', 'currency' => 'EUR'],
['full' => 'Mexico', 'short' => 'MX', 'currency' => 'MXN'],
['full' => 'Micronesia', 'short' => 'FM', 'currency' => 'USD'],
['full' => 'Moldova', 'short' => 'MD', 'currency' => 'MDL'],
['full' => 'Monaco', 'short' => 'MC', 'currency' => 'EUR'],
['full' => 'Mongolia', 'short' => 'MN', 'currency' => 'MNT'],
['full' => 'Montenegro', 'short' => 'ME', 'currency' => 'EUR'],
['full' => 'Montserrat', 'short' => 'MS', 'currency' => 'XCD'],
['full' => 'Morocco', 'short' => 'MA', 'currency' => 'MAD'],
['full' => 'Mozambique', 'short' => 'MZ', 'currency' => 'MZN'],
['full' => 'Myanmar', 'short' => 'MM', 'currency' => 'MMK'],
['full' => 'Namibia', 'short' => 'NA', 'currency' => 'NAD'],
['full' => 'Nauru', 'short' => 'NR', 'currency' => 'AUD'],
['full' => 'Nepal', 'short' => 'NP', 'currency' => 'NPR'],
['full' => 'Netherlands', 'short' => 'NL', 'currency' => 'EUR'],
['full' => 'New Caledonia', 'short' => 'NC', 'currency' => 'XPF'],
['full' => 'New Zealand', 'short' => 'NZ', 'currency' => 'NZD'],
['full' => 'Nicaragua', 'short' => 'NI', 'currency' => 'NIO'],
['full' => 'Niger', 'short' => 'NE', 'currency' => 'XOF'],
['full' => 'Nigeria', 'short' => 'NG', 'currency' => 'NGN'],
['full' => 'Niue', 'short' => 'NU', 'currency' => 'NZD'],
['full' => 'Norfolk Island', 'short' => 'NF', 'currency' => 'AUD'],
['full' => 'North Korea', 'short' => 'KP', 'currency' => 'KPW'],
['full' => 'Northern Mariana Islands', 'short' => 'MP', 'currency' => 'USD'],
['full' => 'Norway', 'short' => 'NO', 'currency' => 'NOK'],
['full' => 'Oman', 'short' => 'OM', 'currency' => 'OMR'],
['full' => 'Pakistan', 'short' => 'PK', 'currency' => 'PKR'],
['full' => 'Palau', 'short' => 'PW', 'currency' => 'USD'],
['full' => 'Palestine', 'short' => 'PS', 'currency' => 'ILS'],
['full' => 'Panama', 'short' => 'PA', 'currency' => 'PAB'],
['full' => 'Papua New Guinea', 'short' => 'PG', 'currency' => 'PGK'],
['full' => 'Paraguay', 'short' => 'PY', 'currency' => 'PYG'],
['full' => 'Peru', 'short' => 'PE', 'currency' => 'PEN'],
['full' => 'Philippines', 'short' => 'PH', 'currency' => 'PHP'],
['full' => 'Pitcairn Islands', 'short' => 'PN', 'currency' => 'NZD'],
['full' => 'Poland', 'short' => 'PL', 'currency' => 'PLN'],
['full' => 'Portugal', 'short' => 'PT', 'currency' => 'EUR'],
['full' => 'Puerto Rico', 'short' => 'PR', 'currency' => 'USD'],
['full' => 'Qatar', 'short' => 'QA', 'currency' => 'QAR'],
['full' => 'Republic of Kosovo', 'short' => 'XK', 'currency' => 'EUR'],
['full' => 'Réunion', 'short' => 'RE', 'currency' => 'EUR'],
['full' => 'Romania', 'short' => 'RO', 'currency' => 'RON'],
['full' => 'Russia', 'short' => 'RU', 'currency' => 'RUB'],
['full' => 'Rwanda', 'short' => 'RW', 'currency' => 'RWF'],
['full' => 'Saint Barthélemy', 'short' => 'BL', 'currency' => 'EUR'],
['full' => 'Saint Helena, Ascension and Tristan da Cunha', 'short' => 'SH', 'currency' => 'SHP'],
['full' => 'Saint Kitts and Nevis', 'short' => 'KN', 'currency' => 'XCD'],
['full' => 'Saint Lucia', 'short' => 'LC', 'currency' => 'XCD'],
['full' => 'Saint Martin', 'short' => 'MF', 'currency' => 'EUR'],
['full' => 'Saint Pierre and Miquelon', 'short' => 'PM', 'currency' => 'EUR'],
['full' => 'Saint Vincent and the Grenadines', 'short' => 'VC', 'currency' => 'XCD'],
['full' => 'Samoa', 'short' => 'WS', 'currency' => 'WST'],
['full' => 'San Marino', 'short' => 'SM', 'currency' => 'EUR'],
['full' => 'São Tomé and Príncipe', 'short' => 'ST', 'currency' => 'STD'],
['full' => 'Saudi Arabia', 'short' => 'SA', 'currency' => 'SAR'],
['full' => 'Senegal', 'short' => 'SN', 'currency' => 'XOF'],
['full' => 'Serbia', 'short' => 'RS', 'currency' => 'RSD'],
['full' => 'Seychelles', 'short' => 'SC', 'currency' => 'SCR'],
['full' => 'Sierra Leone', 'short' => 'SL', 'currency' => 'SLL'],
['full' => 'Singapore', 'short' => 'SG', 'currency' => 'SGD'],
['full' => 'Sint Maarten', 'short' => 'SX', 'currency' => 'ANG'],
['full' => 'Slovakia', 'short' => 'SK', 'currency' => 'EUR'],
['full' => 'Slovenia', 'short' => 'SI', 'currency' => 'EUR'],
['full' => 'Solomon Islands', 'short' => 'SB', 'currency' => 'SDB'],
['full' => 'Somalia', 'short' => 'SO', 'currency' => 'SOS'],
['full' => 'South Africa', 'short' => 'ZA', 'currency' => 'ZAR'],
['full' => 'South Georgia', 'short' => 'GS', 'currency' => 'GBP'],
['full' => 'South Korea', 'short' => 'KR', 'currency' => 'KRW'],
['full' => 'South Ossetia', 'short' => 'HI', 'currency' => 'RUB'],
['full' => 'South Sudan', 'short' => 'SS', 'currency' => 'SSP'],
['full' => 'Spain', 'short' => 'ES', 'currency' => 'EUR'],
['full' => 'Sri Lanka', 'short' => 'LK', 'currency' => 'LKR'],
['full' => 'Sudan', 'short' => 'SD', 'currency' => 'SDG'],
['full' => 'Suriname', 'short' => 'SR', 'currency' => 'SRD'],
['full' => 'Svalbard and Jan Mayen', 'short' => 'SJ', 'currency' => 'NOK'],
['full' => 'Swaziland', 'short' => 'SZ', 'currency' => 'SZL'],
['full' => 'Sweden', 'short' => 'SE', 'currency' => 'SEK'],
['full' => 'Switzerland', 'short' => 'CH', 'currency' => 'CHE'],
['full' => 'Syria', 'short' => 'SY', 'currency' => 'SYP'],
['full' => 'Taiwan', 'short' => 'TW', 'currency' => 'TWD'],
['full' => 'Tajikistan', 'short' => 'TJ', 'currency' => 'TJS'],
['full' => 'Tanzania', 'short' => 'TZ', 'currency' => 'TZS'],
['full' => 'Thailand', 'short' => 'TH', 'currency' => 'THB'],
['full' => 'Timor-Leste', 'short' => 'TL', 'currency' => 'USD'],
['full' => 'Togo', 'short' => 'TG', 'currency' => 'XOF'],
['full' => 'Tokelau', 'short' => 'TK', 'currency' => 'NZD'],
['full' => 'Tonga', 'short' => 'TO', 'currency' => 'TOP'],
['full' => 'Trinidad and Tobago', 'short' => 'TT', 'currency' => 'TTD'],
['full' => 'Tunisia', 'short' => 'TN', 'currency' => 'TND'],
['full' => 'Turkey', 'short' => 'TR', 'currency' => 'TRY'],
['full' => 'Turkmenistan', 'short' => 'TM', 'currency' => 'TMT'],
['full' => 'Turks and Caicos Islands', 'short' => 'TC', 'currency' => 'USD'],
['full' => 'Tuvalu', 'short' => 'TV', 'currency' => 'AUD'],
['full' => 'Uganda', 'short' => 'UG', 'currency' => 'UGX'],
['full' => 'Ukraine', 'short' => 'UA', 'currency' => 'UAH'],
['full' => 'United Arab Emirates', 'short' => 'AE', 'currency' => 'AED'],
['full' => 'United Kingdom', 'short' => 'GB', 'currency' => 'GBP'],
['full' => 'United States', 'short' => 'US', 'currency' => 'USD'],
['full' => 'United States Minor Outlying Islands', 'short' => 'UM', 'currency' => 'USD'],
['full' => 'United States Virgin Islands', 'short' => 'VI', 'currency' => 'USD'],
['full' => 'Uruguay', 'short' => 'UY', 'currency' => 'UYI'],
['full' => 'Uzbekistan', 'short' => 'UZ', 'currency' => 'UZS'],
['full' => 'Vanuatu', 'short' => 'VU', 'currency' => 'VUV'],
['full' => 'Venezuela', 'short' => 'VE', 'currency' => 'VEF'],
['full' => 'Vietnam', 'short' => 'VN', 'currency' => 'VND'],
['full' => 'Wallis and Futuna', 'short' => 'WF', 'currency' => 'XPF'],
['full' => 'Western Sahara', 'short' => 'EH', 'currency' => 'MAD'],
['full' => 'Yemen', 'short' => 'YE', 'currency' => 'YER'],
['full' => 'Zambia', 'short' => 'ZM', 'currency' => 'ZMK'],
['full' => 'Zimbabwe', 'short' => 'ZW', 'currency' => 'ZWL'],
];
29 changes: 29 additions & 0 deletions generator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

$remote = 'https://raw.githubusercontent.com/herrniemand/visas/master/data/info/countries.json';

echo 'Getting data from remote..', PHP_EOL;
$json = file_get_contents($remote);
echo 'Done!', PHP_EOL;

$data = json_decode($json, true);

if (!$data) {
throw new \Exception('Parse data error');
}
$result = [];
foreach ($data as $item) {
$result[] = '[' . implode(',', [
'\'full\' => ' . '\'' . $item['name']['common'] . '\'',
'\'short\' => ' . '\'' . $item['cca2'] . '\'',
'\'currency\' => ' . '\'' . (isset($item['currency'][0]) ? $item['currency'][0] : '') . '\'',
]) . ']';
}
$result = implode(',' . PHP_EOL, $result);
$php = <<<EOF
<?php
return [
$result
];
EOF;
file_put_contents('./data/countries.php', $php);

0 comments on commit a5ae95c

Please sign in to comment.