dostrog / larate
Small library to access to currency exchange rates API of CBRF (Bank of Russia) and NBU (National Bank of Ukraine) from Laravel
Fund package maintenance!
dostrog
Requires
- php: ^7.4|^8.0
- ext-intl: *
- ext-libxml: *
- ext-simplexml: *
- guzzlehttp/guzzle: ^7.2.0
- moneyphp/money: ^3.3
- thecodingmachine/safe: ^1.3
Requires (Dev)
- orchestra/testbench: ^6.0
- phpunit/phpunit: 9.4.*
- rector/rector: ^0.9.29
- roave/security-advisories: dev-master
This package is auto-updated.
Last update: 2024-12-01 00:08:18 UTC
README
Overview
A simple Laravel package used for interacting with the Bank of Russia and National Bank of Ukraine API. 'Larate' allow you to get the latest or historical converted monetary values between RUB (UAH) and other currencies.
Installation
You can install the package via composer:
composer require dostrog/larate
You can publish the config file with:
php artisan vendor:publish --provider="Dostrog\Larate\Providers\LarateServiceProvider" --tag="config"
This is the contents of the published config file:
return [ 'default_base_currency' => 'RUB', 'service' => [ 'RUB' => Dostrog\Larate\Services\RussianCentralBank::class, 'UAH' => Dostrog\Larate\Services\NationalBankOfUkraine::class, ], ];
Usage
// instantiate from Laravel IoC for inject provider // according to config it maybe RUB (converted) rates from Central Bank OF Russia $provider = app()->make(Larate::class); $pair = new CurrencyPair('RUB', 'USD'); $date = Carbon::parse('2020-01-16'); $rate = $provider->getExchangeRate($pair, $date); $value = $rate->getValue(); // 61.4328 // ...or using factory method, i.e. for getting UAH (converted) rates from National Bank of Ukraine $provider = Larate::createForBaseCurrency('UAH'); $pair = new CurrencyPair('UAH', 'USD'); $date = Carbon::parse('2020-01-16'); $rate = $provider->getExchangeRate($pair, $date); $value = $rate->getValue(); // 23.9821 // ...or using Laravel's Facades $rate = LarateFacade::getExchangeRate($pair, $date); $value = $rate->getValue();
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.