chistowick / lettuce
用于接收和处理俄罗斯联邦中央银行API货币汇率的包。
1.1.0
2021-01-16 18:02 UTC
Requires
- php: >=7.4.0
- illuminate/support: ^7.0|^8.0
- monolog/monolog: ^2.0
- nesbot/carbon: ^2.31
Requires (Dev)
This package is auto-updated.
Last update: 2024-09-17 01:58:57 UTC
README
描述
为Laravel准备的包。用于接收和处理俄罗斯联邦中央银行API的货币汇率。
安装
使用Composer
$ composer require chistowick/lettuce
演示
<?php use Chistowick\Lettuce\ExchangeRatesHandler; $erh = new ExchangeRatesHandler(); // Getting the exchange rate relative to the RUB: $erh->usd(); $erh->eur(); // Getting a multiplier for converting one currency to another: $erh->usdToEur(); // It will also work $erh->USD(); $erh->USDToEUR(); // By default, for today: echo "USD = {$erh->usd()} RUB"; echo "EUR = {$erh->eur()} RUB"; echo "USD to EUR = {$erh->usdToEur()}"; // or... // On the selected date in the YYYY-MM-DD format: echo "USD = {$erh->usd('2020-02-29')} RUB"; echo "EUR = {$erh->eur('2020-02-29')} RUB"; echo "USD to EUR = {$erh->usdToEur('2020-02-29')}"; // If you try to get nonexistent data about courses, null is returned. $erh->usd('2099-02-29');
此外
When trying to get data about courses for tomorrow:
1. if the course has not been published yet, null will be returned.
2. if the course is already published, you will receive it.
缓存
接收到的汇率将根据Laravel应用程序配置中的默认驱动器值进行缓存。
日志记录
程序根据Laravel应用程序配置中的默认通道值记录异常和关键点。
配置
可下载货币列表可在包中通过路径 lettuce/config/codes.php 获取。