定制 chroma-x/iso3166-country-information 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

chroma-x/iso3166-country-information

Composer 安装命令:

composer require chroma-x/iso3166-country-information

包简介

ISO3166 util class for validating and listing country codes and getting detailed information for identified countries.

README 文档

README

Build Status Test Coverage SensioLabs Insight Code Climate Latest Stable Version Total Downloads License

ISO3166 util class for validating and listing country codes and getting detailed information for identified countries.

Installation

{
   	"require": {
        "chroma-x/iso3166-country-information": "~3.0"
    }
}

Usage

Autoloading and namesapce

require_once('path/to/vendor/autoload.php');

use ChromaX\Iso3166Country\Iso3166CountryInformation;
use ChromaX\Iso3166Country\Iso3166Country;

Getting information about all countries existing in ISO3166

Get all countries as array of hashmaps containing the country information

$arrayOfIso3166Countries = Iso3166CountryInformation::getCountryData();
Result
…
[RU] => Array
	(
		[iso3166_alpha2] => RU
		[iso3166_alpha3] => RUS
		[iso3166_numeric] => 643
		[iso3166_2] => RU
		[un] => RU
		[tld] => ru
		[name] => Russische Föderation
	)
[SB] => Array
	(
		[iso3166_alpha2] => SB
		[iso3166_alpha3] => SLB
		[iso3166_numeric] => 090
		[iso3166_2] => SB
		[un] => SB
		[tld] => sb
		[name] => Salomonen
)
…

Get all countries as array of Iso3166Country objects

$arrayOfIso3166CountryObjects = Iso3166CountryInformation::getCountries();
Result
…
[CX] => Iso3166Country\Iso3166Country Object
	(
		[iso3166Alpha2CountryCode:Iso3166Country\Iso3166Country:private] => CX
		[iso3166Alpha3CountryCode:Iso3166Country\Iso3166Country:private] => CXR
		[iso3166NumericCountryCode:Iso3166Country\Iso3166Country:private] => 162
		[iso3166_2CountryCode:Iso3166Country\Iso3166Country:private] => CX
		[toplevelDomain:Iso3166Country\Iso3166Country:private] => cx
		[unitedNationsCountryCode:Iso3166Country\Iso3166Country:private] => CX
		[name:Iso3166Country\Iso3166Country:private] => Weihnachtsinsel
	)
[EH] => Iso3166Country\Iso3166Country Object
	(
		[iso3166Alpha2CountryCode:Iso3166Country\Iso3166Country:private] => EH
		[iso3166Alpha3CountryCode:Iso3166Country\Iso3166Country:private] => ESH
		[iso3166NumericCountryCode:Iso3166Country\Iso3166Country:private] => 732
		[iso3166_2CountryCode:Iso3166Country\Iso3166Country:private] => EH
		[toplevelDomain:Iso3166Country\Iso3166Country:private] => eh
		[unitedNationsCountryCode:Iso3166Country\Iso3166Country:private] => EH
		[name:Iso3166Country\Iso3166Country:private] => Westsahara
	)
…

Get all countries as a string containing HTML option tags.

// Argument 1 ('DE') ist the selected option,
// argument 2 (ISO3166_ALPHA2) property is the value,
// argument 2 (NAME) property is the label.
$optionsOfIso3166Countries = Iso3166CountryInformation::getSelectOptions(
	'DE',
	Iso3166CountryInformation::ISO3166_ALPHA2,
	Iso3166CountryInformation::NAME
);

Result

<option value="AF">Afghanistan</option>
<option value="EG">Ägypten</option>
<option value="AX">Åland</option>
<option value="AL">Albanien</option>
<option value="DZ">Algerien</option>
<option value="AS">Amerikanisch-Samoa</option>
<option value="VI">Amerikanische Jungferninseln</option>
<option value="AD">Andorra</option>
…
<option value="DE" selected="selected">Deutchland</option>
…

Getting information about a single country identified by one of the ISO3166 properties

Get info for the ISO3166Alpha2 country code 'de' (Germany)

$iso3166Country = Iso3166CountryInformation::getByIso3166Alpha2('de');

Get info for the ISO3166Alpha3 country code 'deu' (Germany)

$iso3166Country = Iso3166CountryInformation::getByIso3166Alpha3('deu');

Get info for the ISO3166Numeric country code '276' (Germany)

$iso3166Country = Iso3166CountryInformation::getByIso3166Numeric(276);

Get info for the ISO3166-2 country code 'de' (Germany)

$iso3166Country = Iso3166CountryInformation::getByIso3166v2('de');

Get info for the ISO3166 top level domain 'de' (Germany)

$iso3166Country = Iso3166CountryInformation::getByToplevelDomain('de');

Get info for the ISO3166 united nations identifier 'de' (Germany)

$iso3166Country = Iso3166CountryInformation::getByUnitedNationsId('de');
Result
$iso3166Country => Iso3166Country\Iso3166Country Object
	(
		[iso3166Alpha2CountryCode:Iso3166Country\Iso3166Country:private] => DE
		[iso3166Alpha3CountryCode:Iso3166Country\Iso3166Country:private] => DEU
		[iso3166NumericCountryCode:Iso3166Country\Iso3166Country:private] => 276
		[iso3166_2CountryCode:Iso3166Country\Iso3166Country:private] => DE
		[toplevelDomain:Iso3166Country\Iso3166Country:private] => de
		[unitedNationsCountryCode:Iso3166Country\Iso3166Country:private] => DE
		[name:Iso3166Country\Iso3166Country:private] => Deutschland
	)

Validate whether a ISO3166 property is valid (existing)

Whether the ISO3166Alpha2 country code 'de' exists

$countryExists = Iso3166CountryInformation::validateIso3166Alpha2('de');

Whether the ISO3166Alpha3 country code 'deu' exists

$countryExists = Iso3166CountryInformation::validateIso3166Alpha3('deu');

Whether the ISO3166Numeric country code '276' exists

$countryExists = Iso3166CountryInformation::validateIso3166Numeric(276);

Whether the ISO3166-2 country code 'de' exists

$countryExists = Iso3166CountryInformation::validateIso3166v2('de');

Whether the ISO3166 top level domain 'de' exists

$countryExists = Iso3166CountryInformation::validateToplevelDomain('de');

Whether the ISO3166 united nations identifier 'de' exists

$countryExists = Iso3166CountryInformation::validateUnitedNationsId('de');
All validation methods return a boolean value.

Methods of the Iso3166Country class

Creation of an object by country code

use ChromaX\Iso3166Country\Iso3166CountryInformation;
use ChromaX\Iso3166Country\Iso3166Country;

$country = new Iso3166Country();
$country->loadByIso3166Alpha2CountryCode('DE');

Creation of a custom country information object

use Iso3166Country\Iso3166CountryInformation;
use Iso3166Country\Iso3166Country;

$utopia = array(
	Iso3166CountryInformation::ISO3166_ALPHA2 => 'UO',
	Iso3166CountryInformation::ISO3166_ALPHA3 => 'UTO',
	Iso3166CountryInformation::ISO3166_NUMERIC => 42,
	Iso3166CountryInformation::ISO3166_2 => 'UO',
	Iso3166CountryInformation::UNITED_NATIONS_ID => 'uo',
	Iso3166CountryInformation::TOP_LEVEL_DOMAIN => 'uo',
	Iso3166CountryInformation::NAME => 'Utopia'
);
$country = new Iso3166Country();
$country->loadByIso3166CountryInformation($utopia);

Getter for properties

$iso3166Alpha2 = $country->getIso3166Alpha2CountryCode();
$iso3166Alpha3 = $country->getIso3166Alpha3CountryCode();
$iso3166Numeric = $country->getIso3166NumericCountryCode();
$iso3166_2 = $country->getIso3166v2CountryCode();
$toplevelDomain = $country->getToplevelDomain();
$unitedNationsIdentifier = $country->getUnitedNationsId();
$name = $country->getName();

Contribution

Contributing to our projects is always very appreciated.
But: please follow the contribution guidelines written down in the CONTRIBUTING.md document.

License

PHP ISO3166 Country Information is under the MIT license.

chroma-x/iso3166-country-information 适用场景与选型建议

chroma-x/iso3166-country-information 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.86k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 01 月 18 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「Iso3166」 「country code」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 chroma-x/iso3166-country-information 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 chroma-x/iso3166-country-information 我们能提供哪些服务?
定制开发 / 二次开发

基于 chroma-x/iso3166-country-information 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 1.86k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 10
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-01-18