World
Make it simple to work with locations and data about the world, (*1)
It should be easy to do things like get a list of US States, Canadian
Provinces, and to determine if a postal code or phone number is valid.
Some countries don't use postal codes at all, phone numbers have different
criteria across countries. This library aims to make things a little easier., (*2)
For every country object, you can access the following information:, (*3)
- Common Name
- Official Name
- ISO 3166-1 alpha 2 code (e.g. US for United States)
- ISO 3166-2 alpha 3 code (e.g. USA for United States)
- ISO 4127 Currency code (e.g. USD for United States Dollars)
- The Continent
The available interfaces are:, (*4)
- PhoneNumberInterface - provide phone number validation method signatures
- PostalCodeInterface - provide postal code validation method signatures
- SubdivisionInterface - provide a subdivision list, e.g. provinces in Canada
The available traits are:, (*5)
- NorthAmericanPhoneNumber
- ZipCode
Version
The current version is 0.2.0. This project uses semantic versioning., (*6)
License
This is licensed under the MIT License., (*7)
Example Code
Retrieve Single Country
require 'vendor/autoload.php';
$usa = Awoods\World\CountryFactory::get('US');
echo $usa->getOfficialName(); // Unites States of America
$canada = Awoods\World\CountryFactory::get('CAN');
echo $canada->getCommonName(); // Canada
Loop Over All Countries
require "vendor/autoload.php";
$countryFactory = new \Awoods\World\CountryFactory();
$countries = $countryFactory->getAllCountries();
foreach ($countries AS $code => $name) {
echo "\n";
echo "{$code} is the code for {$name}\n";
$country = $countryFactory->create($code);
echo "The official name for {$name} is '{$country->getFullName()}'\n";
echo "Here is a list of it's localities:\n";
foreach ($country->getLocalityList() AS $localityCode => $localityName) {
echo "* {$localityName} ({$localityCode})\n";
}
}
echo "\n";
Currently Supported Countries
North America
The countries have additional phone number and postal code validation methods, (*8)
- United States
- Canada
- Mexico
The countries have basic Country support, (*9)
- Anguilla
- Antigua and Barbuda
- Aruba
- Bahamas
- Barbados
- Belize
- Bermuda
- British Virgin Islands
- Caribbean Netherlands
- Cayman Islands
- Costa Rica
- Cuba
- Curaçao
- Dominica
- Dominican Republic
- El Salvador
- Greenland
- Grenada
- Guadeloupe
- Guatemala
- Haiti
- Honduras
- Jamaica
- Martinique
- Montserrat
- Nicaragua
- Panama
- Puerto Rico
- Sint Maarten
- St. Barthélemy
- St. Kitts and Nevis
- St. Lucia
- St. Martin
- St. Pierre and Miquelon
- St. Vincent and Grenadines
- Trinidad and Tobago
- Turks and Caicos Islands
- U.S. Virgin Islands
Upcoming Countries
-
South America, (*10)
-
Europe, (*11)
-
Asia, (*12)
-
Africa, (*13)
-
Oceania, (*14)
-
Antarctica, (*15)
Ideas for sections/pages
-
Traits, (*16)
-
Features, (*17)
-
Language Translations, (*18)
These 5 languages plus English should cover most developers in the world, (*19)
- Spanish
- French
- Hindi
- Chinese (Mandarin)
- Arabic
-
Frequently Asked Questions (FAQ), (*20)
- Screenshots
- Submit Issues
Credits and Acknowledgments