alldigitalrewards / country-mapper
国家映射库
1.10.0
2024-07-02 16:33 UTC
Requires
- php: ^7.0|^8.0
- ext-json: *
- guzzlehttp/guzzle: ^6.5|^7.0
- league/iso3166: ~2.1.5|^3.0|^4.0
Requires (Dev)
- phpunit/phpunit: ^7.0|^8|^9
- roave/security-advisories: dev-latest
- squizlabs/php_codesniffer: ^3.0
This package is auto-updated.
Last update: 2024-09-02 16:52:50 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