alzpk/restcountries-eu-api

此包已被 废弃 且不再维护。作者建议使用 alzpk/restcountries-php-api-wrapper 包代替。

Restcountries.eu API PHP 封装器

2.0.0 2021-09-16 17:36 UTC

README

包已被废弃

请使用此替代: https://packagist.org.cn/packages/alzpk/restcountries-php-api-wrapper

Restcountries.eu API PHP 封装器

Restcountries.eu API PHP 封装器,基于 API 响应返回带有值对象的模型。

要求

{
  "php": "^7.4",
  "guzzlehttp/guzzle": "7.4.2",
  "ext-json": "*"
}

安装

composer require alzpk/restcountries-eu-api

使用示例

$client = new \Alzpk\RestCountriesEuAPI\RestCountriesClient();

// Fetch all countries
$countries = $client->all();

// Fetch countries by searching names
$countries = $client->name('Denmark');

客户端映射

方法 参数 示例
all $client->all();
name (string) 国家名称 $client->name('Denmark');
code (string) 国家代码 $client->code('208');
codes (array) 国家代码列表 $client->codes(['208', '209']);
currency (string) 国家货币 $client->curency('DKK');
language (string) 国家语言 $client->language('da');
callingCode (string) 国家拨打代码 $client->callingCode('45');
region (string) 国家区域 $client->region('Europe');
regionalBloc (string) 国家区域集团 $client->regionalBloc('EU');

测试

该包包含对模型、值对象和封装器的单个测试。