ksdev/nbp-currency-converter
最新稳定版本:0.2.3
Composer 安装命令:
composer require ksdev/nbp-currency-converter
包简介
Retrieve average currency exchange rates from the NBP website and convert an amount from one currency to another.
README 文档
README
Retrieve average currency exchange rates from the NBP website and convert an amount from one currency to another.
Install
Via Composer
$ composer require ksdev/nbp-currency-converter
Usage
If optional table publication date is not passed to convert or averageExchangeRates methods, the last published
average exchange rates table will be used, starting from yesterday, so e.g. on 2015-07-10 (friday) a table from
2015-07-09 (thursday) will be used, and on 2015-07-12 (sunday) a table from 2015-07-10 (friday) - unless no table was
published on this day, then the table from previous day will be used, etc.
use Ksdev\NBPCurrencyConverter\CurrencyConverter; use Ksdev\NBPCurrencyConverter\ExRatesTableFinder; use Ksdev\NBPCurrencyConverter\ExRatesTableFactory; use GuzzleHttp\Client; $converter = new CurrencyConverter( new ExRatesTableFinder( new Client(), new ExRatesTableFactory(), 'path/to/cache/folder' ) ); try { $result = $converter->convert('123.4567', 'PLN', 'USD'); $avgExRates = $converter->averageExchangeRates(); } catch (Exception $e) { // }
$result
array( 'publication_date' => '2015-07-03', 'amount' => '32.7246', 'currency' => 'USD' );
$avgExRates
array( 'numer_tabeli' => '127/A/NBP/2015', 'data_publikacji' => '2015-07-03', 'waluty' => array( 'PLN' => array( 'nazwa_waluty' => 'złoty polski', 'przelicznik' => '1', 'kurs_sredni' => '1', ), 'THB' => array( 'nazwa_waluty' => 'bat (Tajlandia)', 'przelicznik' => '1', 'kurs_sredni' => '0,1117', ), 'USD' => array( 'nazwa_waluty' => 'dolar amerykański', 'przelicznik' => '1', 'kurs_sredni' => '3,7726', ), 'AUD' => array(...) ) );
Testing
$ composer test
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 16.58k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-07-04