datablock / countrycodes
Country codes and other info.
Installs: 8
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/datablock/countrycodes
This package is auto-updated.
Last update: 2025-11-16 04:12:17 UTC
README
Install
composer install datablock/countrycodes
Usage
New instance
new CountryCodes([?string $country=null]);
Parameters :
$countrystring to define a specific country.
Example :
use \Datablock\CountryCodes\CountryCodes; // ... $countrycodes = new CountryCodes(); $countrycodes = new CountryCodes('FR');
Set the country
Define or orverride the country definition :
$countrycodes->setCountry(string $country);
Parameters :
$countrystring (required) to define a specific country.
use \Datablock\CountryCodes\CountryCodes; // ... $countrycodes = new CountryCodes(); // ... $countrycodes->setCountry('FR');
Database
Getting database as PHP array :
- If the
$countryis not defined,getDatabasereturn the full database. - If the
$countryis defined,getDatabasereturn the database for the country.
$countrycodes->getDatabase([?string $country=null]);
getDatabasereturn data as PHP array.getJsonDatabasereturn data as JSON file.
Parameters :
$countrystring to define a specific country.
Examples :
-
Example 1 (Full database) :
use \Datablock\CountryCodes\CountryCodes; // ... $countrycodes = new CountryCodes(); // ... $countrycodes->getDatabase();
-
Example 2 (Database for a specific country on instance) :
use \Datablock\CountryCodes\CountryCodes; // ... $countrycodes = new CountryCodes('FR'); // ... $countrycodes->getDatabase();
-
Example 3 (Database for a specific country after instance) :
use \Datablock\CountryCodes\CountryCodes; // ... $countrycodes = new CountryCodes(); // ... $countrycodes->setCountry('FR'); // ... $countrycodes->getDatabase();
-
Example 4 (Database for a specific country only for the method) :
use \Datablock\CountryCodes\CountryCodes; // ... $countrycodes = new CountryCodes(); // ... $countrycodes->getDatabase('FR');
Get Country Name
- If the
$countryis not defined,getCountryNamereturn the associative array of['country_code'] => "Country name". - If the
$countryis defined,getCountryNamereturn the name of the country.
$countrycodes->getCountryName([?string $country=null]);
Parameters & Examples : same as getDatabase
Get the code ISO Alpha 2
- If the
$countryis not defined,getIso2return the associative array of['country_code'] => "Country ISO 2". - If the
$countryis defined,getIso2return the code iso alpha 2 of the country.
$countrycodes->getIso2([?string $country=null]);
Parameters & Examples : same as getDatabase
Get the code ISO Alpha 3
- If the
$countryis not defined,getIso3return the associative array of['country_code'] => "Country ISO 3". - If the
$countryis defined,getIso3return the code iso alpha 3 of the country.
$countrycodes->getIso3([?string $country=null]);
Parameters & Examples : same as getDatabase
Get the TLD
- If the
$countryis not defined,getTldreturn the associative array of['country_code'] => "Country TLD". - If the
$countryis defined,getTldreturn the TLD of the country.
$countrycodes->getTld([?string $country=null]);
Parameters & Examples : same as getDatabase
Get the code FIPS
- If the
$countryis not defined,getFipsreturn the associative array of['country_code'] => "Country FIPS". - If the
$countryis defined,getFipsreturn the code FIPS of the country.
$countrycodes->getFips([?string $country=null]);
Parameters & Examples : same as getDatabase
Get the code ISO Numeric
- If the
$countryis not defined,getIsoNumericreturn the associative array of['country_code'] => "Country ISO Numeric". - If the
$countryis defined,getIsoNumericreturn the code iso numeric of the country.
$countrycodes->getIsoNumeric([?string $country=null]);
Parameters & Examples : same as getDatabase
Get the geoname ID
- If the
$countryis not defined,getGeonameIdreturn the associative array of['country_code'] => "Country Geoname ID". - If the
$countryis defined,getGeonameIdreturn the geoname ID of the country.
$countrycodes->getGeonameId([?string $country=null]);
Parameters & Examples : same as getDatabase
Get the E164
- If the
$countryis not defined,getE164return the associative array of['country_code'] => "Country E164". - If the
$countryis defined,getE164return the E164 of the country.
$countrycodes->getE164([?string $country=null]);
Parameters & Examples : same as getDatabase
Get the PhoneCode
- If the
$countryis not defined,getPhoneCodereturn the associative array of['country_code'] => "Country PhoneCode". - If the
$countryis defined,getPhoneCodereturn the PhoneCode of the country.
$countrycodes->getPhoneCode([?string $country=null]);
Parameters & Examples : same as getDatabase
Get the Continent
- If the
$countryis not defined,getContinentreturn the associative array of['country_code'] => "Country Continent". - If the
$countryis defined,getContinentreturn the Continent of the country.
$countrycodes->getContinent([?string $country=null]);
Parameters & Examples : same as getDatabase
Get the Capital
- If the
$countryis not defined,getCapitalreturn the associative array of['country_code'] => "Country Capital". - If the
$countryis defined,getCapitalreturn the Capital of the country.
$countrycodes->getCapital([?string $country=null]);
Parameters & Examples : same as getDatabase
Get the Timezone
- If the
$countryis not defined,getTimezonereturn the associative array of['country_code'] => "Country Timezone". - If the
$countryis defined,getTimezonereturn the Timezone of the country.
$countrycodes->getTimezone([?string $country=null]);
Parameters & Examples : same as getDatabase
Get the Currency
- If the
$countryis not defined,getCurrencyreturn the associative array of['country_code'] => "Country Currency". - If the
$countryis defined,getCurrencyreturn the Currency of the country.
$countrycodes->getCurrency([?string $country=null]);
Parameters & Examples : same as getDatabase
Get the LanguageCodes
- If the
$countryis not defined,getLanguageCodesreturn the associative array of['country_code'] => "Country LanguageCodes". - If the
$countryis defined,getCurrencyreturn the LanguageCodes of the country.
$countrycodes->getLanguageCodes([?string $country=null]);
Parameters & Examples : same as getDatabase
Get the Languages
- If the
$countryis not defined,getLanguagesreturn the associative array of['country_code'] => "Country Languages". - If the
$countryis defined,getLanguagesreturn the Languages of the country.
$countrycodes->getLanguages([?string $country=null]);
Parameters & Examples : same as getDatabase
Get the Area
- If the
$countryis not defined,getAreareturn the associative array of['country_code'] => "Country Area". - If the
$countryis defined,getAreareturn the Area of the country.
$countrycodes->getArea([?string $country=null]);
Parameters & Examples : same as getDatabase