mibo/currency-rates
最新稳定版本:1.2.0
Composer 安装命令:
composer require mibo/currency-rates
包简介
PHP Library that provides currency rates and conversions
关键字:
README 文档
README
Online currency rate provider.
The library comes with \MiBo\Currency\Rates\ExchangerInterface interface, which provides the following methods:
getDefaultCurrency()- returns default currency code of the Exchanger (e.g. USD)getRateFor()- returns rate for the given currency code. Comparing the default currency of the Exchanger if no 'fromCurrency' parameter is provided.getExchangeRates()- list of all exchange rates of the Exchanger. The result is an array where a key is a currency code and a value of 'rate' sub key is a rate for the given currency code. Comparing the default currency of the Exchanger. If 'amount' sub key is present, the rate is calculated for the given amount.getAvailableCurrencies()- returns list of available currencies of the Exchanger. The result is an array of currency codes.
The library comes with a few implementations of the Exchangers:
- ECB - European Central Bank (since 1.0)
- CNB - Czech National Bank (since 1.0)
- BoE - Bank of England (since 1.1)
- CF - Currency Freaks (since 1.2)
- OXR - Open Exchange Rates (since 1.2) - Experimental
- more to come...
All implementations load the rates from publicly available resources. All resources are located on official websites of the banks, thus the rates are trustworthy and up to date.
Installation
composer require mibo/currency-rates
Usage
$price = 100; // EUR $exchanger = new \MiBo\Currency\Rates\Exchangers\ECB(); $newPrice = $exchanger->getRateFor('USD') * $price; // USD
Future of the library
The library will contain more implementations of the Exchangers. The goal is to provide a simple way to get currency rates from various sources. The main focus is on the banks that are globally recognized.
统计信息
- 总下载量: 6.79k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-06-21