tyryshkinm / exchange-rates
There is no license information available for the latest version (v1.0.1) of this package.
PHP library to retrieve exchange rate from cbr.ru and rbc.ru services.
v1.0.1
2020-12-02 23:25 UTC
Requires
- ext-json: *
- ext-libxml: *
- ext-simplexml: *
Requires (Dev)
- phpunit/phpunit: 9.4.4
This package is auto-updated.
Last update: 2025-05-29 01:22:52 UTC
README
$ composer require tyryshkinm/exchange-rates
Usage
use Tyryshkinm\ExchangeRates\ExchangeRates; use Tyryshkinm\ExchangeRates\Factory\ProviderFactory; use Tyryshkinm\ExchangeRates\Http\Client; $currency = 'USD'; // USD and EUR are available only. $date = new \DateTime(); $client = new Client(); $providerFactory = new ProviderFactory($client); $exchangeRateModel = new ExchangeRates(...$providerFactory->getProviders()); // for adding your own provider $myOwnProvider = new MyOwnProvider(); // need implement ProviderInterface $exchangeRateModel->addProvider($myOwnProvider); $averageRate = $exchangeRateModel->getAverageRate($currency, $date);