https://github.com/hollodotme/iso-country-codes
A value object collection representing ICO-3166-1 country codes
https://github.com/hollodotme/iso-country-codes
country-codes iso-3166-1 value-object
Last synced: 2 months ago
JSON representation
A value object collection representing ICO-3166-1 country codes
- Host: GitHub
- URL: https://github.com/hollodotme/iso-country-codes
- Owner: hollodotme
- Created: 2020-08-17T11:32:34.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-08-17T16:39:21.000Z (about 5 years ago)
- Last Synced: 2025-06-02T05:23:57.880Z (5 months ago)
- Topics: country-codes, iso-3166-1, value-object
- Language: HTML
- Homepage:
- Size: 44.9 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: .github/CONTRIBUTING.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README


# ISO-3166-1 country codes
This is a statically generated value object collection of [ISO-3166-1](https://en.wikipedia.org/wiki/ISO_3166-1) country
codes with their following representations:
* English short name
* French short name
* Alpha-2 code
* Alpha-3 code
* Numeric code
Source of the data is: https://www.iso.org/obp/ui/#search/code/
## Requirements
* PHP >= 7.4
## Installation
The recommended way to install this library is using [composer](https://getcomposer.org).
```bash
composer require "hollodotme/iso-country-codes"
```
## Usage
### From English short name
```php
getEnglishShortName(), "\n";
echo $countryCode->getFrenchShortName(), "\n";
echo $countryCode->getAlpha2Code(), "\n";
echo $countryCode->getAlpha3Code(), "\n";
echo $countryCode->getNumericCode();
```
**Prints:**
```
New Caledonia
Nouvelle-Calédonie (la)
NC
NCL
540
```
### From French short name
```php
getEnglishShortName(), "\n";
echo $countryCode->getFrenchShortName(), "\n";
echo $countryCode->getAlpha2Code(), "\n";
echo $countryCode->getAlpha3Code(), "\n";
echo $countryCode->getNumericCode();
```
**Prints:**
```
New Caledonia
Nouvelle-Calédonie (la)
NC
NCL
540
```
### From alpha-2 code
```php
getEnglishShortName(), "\n";
echo $countryCode->getFrenchShortName(), "\n";
echo $countryCode->getAlpha2Code(), "\n";
echo $countryCode->getAlpha3Code(), "\n";
echo $countryCode->getNumericCode();
```
**Prints:**
```
New Caledonia
Nouvelle-Calédonie (la)
NC
NCL
540
```
### From alpha-3 code
```php
getEnglishShortName(), "\n";
echo $countryCode->getFrenchShortName(), "\n";
echo $countryCode->getAlpha2Code(), "\n";
echo $countryCode->getAlpha3Code(), "\n";
echo $countryCode->getNumericCode();
```
**Prints:**
```
New Caledonia
Nouvelle-Calédonie (la)
NC
NCL
540
```
### From numeric code
```php
getEnglishShortName(), "\n";
echo $countryCode->getFrenchShortName(), "\n";
echo $countryCode->getAlpha2Code(), "\n";
echo $countryCode->getAlpha3Code(), "\n";
echo $countryCode->getNumericCode();
```
**Prints:**
```
New Caledonia
Nouvelle-Calédonie (la)
NC
NCL
540
```