rebilly/country
最新稳定版本:v1.1.3
Composer 安装命令:
composer require rebilly/country
包简介
country
关键字:
README 文档
README
Country Project
Overview
This project manages Country information as Value Objects.
Installation
Simply add a dependency on rebilly/country to your project's composer.json file if you use Composer to manage the dependencies of your project.
Classes / Objects
Country
A value object representing a country.
The identifiers are ISO 3166-1 codes (alphabetic and numeric).
The currency values used are ISO 4217 codes.
CountryRepository
The Repository contains a collection of Country objects with the ability to find Countries based on several of the attributes.
AdministrativeArea
A value object representing a province/state/territory/region. Because there is inconsistent naming from country to country, we use the term Administrative Area.
The identifiers are ISO 3166-2 codes (alphabetic and numeric).
AdministrativeAreaRepository
The Repository contains a collection of AdministrativeArea objects with the ability to find AdministrativeAreas based on several of the attributes or by Country.
Usage
use Country\AdministrativeAreaRepository; use Country\CountryRepository; $countryRepository = new CountryRepository(); $administrativeAreaRepository = new AdministrativeAreaRepository($countryRepository); // get a list of all countries $countries = $countryRepository->findAll(); if ($countryRepository->hasWithIsoAlpha2('US')) { $usa = $countryRepository->findByIsoAlpha2('US'); echo $usa->getCommonName(); // United States echo $usa->getOfficialName(); // United States of America // get a list of all US states $administrativeAreaRepository->findByCountry($usa); if ($administrativeAreaRepository->hasWithNameAndCountry('New York', $usa)) { $newYork = $administrativeAreaRepository->findByNameAndCountry('New York', $usa); echo $newYork->getCode(); // NY } }
Tests
phpunit
Security
If you discover a security vulnerability, please report it to security at rebilly dot com.
License
The Country library is open-sourced under the MIT License distributed with the software.
统计信息
- 总下载量: 457.25k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-12-08