alldigitalrewards/country-mapper

1.10.0 2024-07-02 16:33 UTC

README

这是一个国家映射器,可以将国家Alpha或数字代码进行映射

安装

通过Composer

$ composer require alldigitalrewards/country-mapper

使用方法

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());

测试

$ composer test