imitronov / cbrf-currency-rate
There is no license information available for the latest version (1.0.2) of this package.
1.0.2
2023-02-16 20:32 UTC
Requires
- php: >=7.1.3||^8.0
- ext-bcmath: *
- ext-simplexml: *
- symfony/http-client: >=4.4
README
Данная библиотека забирает данные о курсе валют от Центрального Банка РФ.
Доки ЦБ РФ по используемой XML: https://cbr.ru/development/SXML/
Установка
composer require imitronov/cbrf-currency-rate
Использование
<?php // ... use Imitronov\CbrfCurrencyRate\Client; $cbrf = new Client(); $currencyRates = $cbrf->getCurrencyRates(); /** * Перебор всех доступных валют */ foreach ($currencyRates as $currencyRate) { echo sprintf( '1 %s = %s RUB' . PHP_EOL, $currencyRate->getCharCode(), $currencyRate->getRate() ); } /** * Получение курса по нужной валюте */ $usdCurrencyRate = $cbrf->getCurrencyRateByCharCode('USD'); echo sprintf( '1 %s = %s RUB', $usdCurrencyRate->getCharCode(), $usdCurrencyRate->getRate(), );