alldigitalrewards/country-mapper

Country Mapper Library

1.10.0 2024-07-02 16:33 UTC

README

This is a Country mapper which maps a Country Alpha or Numeric code

Install

Via Composer

$ composer require alldigitalrewards/country-mapper

Usage

These calls throw CountryMapperException

**Get Whitelisted Iso**:

$iso = (new CountryInputMapperService())->getWhitelistedIso(840);
$this->assertSame('840', $iso);

**Get Whitelisted Alpha2**:

$alpha = (new CountryInputMapperService())->getWhitelistedAlpha2('US');
$this->assertSame('US', $alpha);

**Get Country by Input (accepts iso/alpha2)**:

$country = (new CountryInputMapperService())->getMappedCountry('840');
$this->assertInstanceOf(Country::class, $country);
$this->assertSame('US', $country->getAlpha2());
$this->assertSame('840', $country->getNumeric());

Testing

$ composer test