mrcage / chf-exchange-rates
根据瑞士联邦海关管理局网站的数据,检索外币的瑞士法郎汇率。
3.0.0
2023-08-09 18:32 UTC
Requires
- php: ^8.1.
- illuminate/support: ^9|^10
- nesbot/carbon: ^2.0
Requires (Dev)
- phpunit/phpunit: ^9.0|^10.0
README
根据瑞士联邦海关管理局网站的数据,检索外币的瑞士法郎汇率。
该库使用内部缓存请求的数据(缓存时间为一周)。
用法
包含类
use MrCage\EzvExchangeRates\EzvExchangeRates;
获取当前日期的汇率
$rate = EzvExchangeRates::getExchangeRate('EUR');
获取过去某天的汇率
日期必须指定为 Carbon 日期对象。
$rate = EzvExchangeRates::getExchangeRate('USD', Carbon::yesterday());
获取所有可用的货币
$currencies = EzvExchangeRates::listCurrencies();
这将返回一个包含货币代码的数组,键为(大写)货币代码,值为汇率使用的基准值。