PHPackages                             graftak/country-code-helper - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. graftak/country-code-helper

ActiveLibrary

graftak/country-code-helper
===========================

Simple package to assist you in converting/mapping ISO 3166-1 Alpha-2, Alpha-3, and Numeric Country Codes.

v2.0.0(8y ago)6227.8k↓16.1%1BSD-3-ClausePHPPHP &gt;=5.6

Since Jul 29Pushed 8y ago1 watchersCompare

[ Source](https://github.com/graftak/country-code-helper)[ Packagist](https://packagist.org/packages/graftak/country-code-helper)[ Docs](https://github.com/graftak/country-code-helper)[ RSS](/packages/graftak-country-code-helper/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (4)Used By (1)

Country Code Helper - Easily map ISO 3166-1 country codes
=========================================================

[](#country-code-helper---easily-map-iso-3166-1-country-codes)

Simple package to assist you in converting/mapping ISO 3166-1 Alpha-2, Alpha-3, and Numeric Country Codes.

Installation
------------

[](#installation)

Install the latest version with

```
$ composer require graftak/country-code-helper
```

Usage
-----

[](#usage)

Include these two classes:

```
use Graftak\CountryCodeHelper;
use Graftak\CountryCodeHelper\CountryCodes;
```

Then, in your code, just use the static method `map`:

```
CountryCodeHelper::map($value, $toType);
```

The first parameter `$value` is the country code (string) you want to map **from**. For example:

- `'NL'` (2-letter country code for The Netherlands)
- `'BRA'` (3-letter country code for Brazil)
- `'024'` (numeric country code for Angola)

The second parameter `$toType` is the type you want to map **to**. These types are supported:

```
CountryCodes::ALPHA_2
CountryCodes::ALPHA_3
CountryCodes::NUMERIC
CountryCodes::SHORT_NAME_ENGLISH
CountryCodes::SHORT_NAME_FRENCH

```

Optionally you can supply the third parameter to explicitly define the type of the given `$value` (you can use any of the constants above).

### Examples

[](#examples)

```
