predicthq/address-formatter
最新稳定版本:v1.1.0
Composer 安装命令:
composer require predicthq/address-formatter
包简介
Address formatter using country templates from https://github.com/OpenCageData/address-formatting
关键字:
README 文档
README
This library uses the address templates from https://github.com/OpenCageData/address-formatting to format addresses differently depending on the country.
Installation
Install the latest version with
$ composer require predicthq/address-formatter
Examples
You can use either the Address object or provide an array of address parts.
use PredictHQ\AddressFormatter\Address; $a = new Address(); $a->setCity('Wellington') ->setCountry('New Zealand') ->setCountryCode('NZ') ->setCounty('Wellington City') ->setHouseNumber(53) ->setPostcode(6011) ->setRoad('Pirie Street') ->setState('Wellington') ->setSuburb('Mount Victoria'); $text = $a->format(); /** * Will display as: * * 53 Pirie Street * Mount Victoria * Wellington 6011 * New Zealand */ echo $text;
Or, pass an array of address parts to the Formatter.
use PredictHQ\AddressFormatter\Formatter; $address = [ 'city' => 'Wellington', 'country' => 'New Zealand', 'country_code' => 'NZ', 'county' => 'Wellington City', 'house_number' => 53, 'postcode' => 6011, 'road' => 'Pirie Street', 'state' => 'Wellington', 'suburb' => 'Mount Victoria', ]; /** * Will display as: * * 53 Pirie Street * Mount Victoria * Wellington 6011 * New Zealand */ $f = new Formatter(); $actual = $f->formatArray($address);
Tests
Run tests using ./vendor/bin/phpunit
统计信息
- 总下载量: 176.94k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 31
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-04-26