brunoinds / sunat-dolar-laravel
v1.1.0
2024-04-03 12:09 UTC
README
一个基于秘鲁 SUNAT 汇率的 PHP 库,用于货币兑换。
安装
通过 Composer 安装
composer require brunoinds/sunat-dolar-laravel
使用方法
Exchange
类提供用于 PEN 和 USD 之间兑换的方法
use Brunoinds\SunatDolarLaravel\Exchange; use Brunoinds\SunatDolarLaravel\Enums\Currency; // Get current exchange rate $result = Exchange::now()->convert(Currency::USD, 1)->to(Currency::PEN); // Get historical exchange rate $date = new DateTime('2023-12-10'); $result = Exchange::on($date) ->convert(Currency::USD, 1) ->to(Currency::PEN); echo $result // 0.27 // Get buy/sell prices $dollarBuy = Exchange::on($date)->getDollarBuyPrice(); //3.749; $solesSell = Exchange::on($date)->getSolesSellPrice(); //0.266
Currency
枚举提供支持的货币常量
use Brunoinds\SunatDolarLaravel\Enums\Currency; Currency::USD; // 'USD' Currency::PEN; // 'PEN'
测试
单元测试位于 tests
目录。使用以下命令运行测试
composer test
贡献
欢迎提交拉取请求!
许可证
MIT 许可证
由
如果您希望扩展任何部分或有其他反馈,请告知!