cryonighter / currency-converter
此包允许您根据俄罗斯中央银行的汇率进行货币兑换(但您可以使用任何其他汇率来源)
1.0.0
2022-02-07 15:35 UTC
Requires
- php: >=8.1.0
- mtownsend/xml-to-array: ^2.0
Requires (Dev)
- phpunit/phpunit: ^9.5.13
This package is not auto-updated.
Last update: 2024-09-18 06:20:37 UTC
README
此包允许您根据俄罗斯中央银行的汇率进行货币兑换(但您可以使用任何其他汇率来源)
亮点
系统需求
您需要
- PHP >= 8.1.0但建议使用最新稳定版本的PHP
安装
通过Composer
$ composer require cryonighter/currency-converter
用法
use Cryonighter\CurrencyConverter\CurrencyCodeConverter; use Cryonighter\CurrencyConverter\CurrencyConverter; use Cryonighter\CurrencyConverter\Provider\CbrCurrencyRateProvider; // Get a list of exchange rates. By default, the package provides a service for receiving rates from the server of the Central Bank of Russia. // However, you can use any source of currency rates, you only need to form an array of instances of the CurrencyRate class. $currencyRates = CbrCurrencyRateProvider::getCurrencyRates(); // Build the converter object $currencyConverter = new CurrencyConverter(new CurrencyCodeConverter(), $currencyRates); // To convert 100 USD to EUR $amount = $currencyConverter->convert(100, 'USD', 'EUR'); // You can also use numeric currency codes $amount = $currencyConverter->convert(100, '840', '978'); // You can mix and match :) $amount = $currencyConverter->convert(100, '840', 'EUR');
变更日志
有关最近变更的更多信息,请参阅CHANGELOG。
测试
$ php vendor/phpunit/phpunit/phpunit tests
贡献
有关详细信息,请参阅CONTRIBUTING和CODE_OF_CONDUCT。
安全
如果您发现任何与安全相关的问题,请通过电子邮件cryonighter@yandex.ru
联系,而不是使用问题跟踪器。
鸣谢
许可证
MIT许可证(MIT)。有关更多信息,请参阅许可证文件。