The package for receiving and processing currency rates from the Central Bank of the Russian Federation API.
chistowick/lettuce is a Laravel package for the package for receiving and processing currency rates from the central bank of the russian federation api..
It currently has 0 GitHub stars and 6 downloads on Packagist (latest version 1.1.0).
Install it with composer require chistowick/lettuce.
Discover more Laravel packages by chistowick
or browse all Laravel packages to compare alternatives.
Last updated
The package for Laravel. For receiving and processing currency rates from the Central Bank of the Russian Federation API.
$ 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.
The received courses will be cached according to the default driver value in the configuration of your Laravel application.
The program logs exceptions and key points according to the default channel value in the configuration of your Laravel application.
The list of downloadable currencies is available in the package by the path: lettuce/config/codes.php