ksaveras / lb-fx-rates
LB Fx Rates client
v0.1.1
2026-03-05 15:44 UTC
Requires
- php: ^8.3
- ext-simplexml: *
- psr/http-client: ^1.0.3
- psr/http-factory: ^1.1
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.93.1
- nyholm/psr7: ^1.8.2
- phpstan/phpstan: ^2.1.38
- phpstan/phpstan-phpunit: ^2.0.14
- phpunit/phpunit: ^12.5.14
- rector/rector: ^2.3.6
- symfony/http-client: ^7.4.5
Suggests
- symfony/http-client: Allows using Symfony HttpClient for requests
This package is auto-updated.
Last update: 2026-03-13 18:12:13 UTC
README
More information: https://www.lb.lt/webservices/fxrates/
Installation
composer require ksaveras/lb-fx-rates
Use cases
Basic example
Fetch FX rates from LB API. Using Symfony HttpClient to fetch data.
use Ksaveras\LBFxRates\PsrClient; use Symfony\Component\HttpClient\Psr18Client; // Psr18Client implements all three required interfaces $psr18Client = new Psr18Client(); $fxRatesClient = new PsrClient( $psr18Client, $psr18Client, $psr18Client, ); $fxRates = $fxRatesClient->currentFxRates(); foreach ($fxRates as $fxRate) { echo sprintf( "%s: %.4f %s == %.4f %s\n", $fxRate->date()->format('Y-m-d'), $fxRate->currencyAmount()->amount(), $fxRate->currencyAmount()->currency()->value, $fxRate->targetCurrencyAmount()->amount(), $fxRate->targetCurrencyAmount()->currency()->value, ); }
This will output something like:
2024-08-31: 1.0000 EUR == 1.6542 AUD
2024-08-31: 1.0000 EUR == 1.9558 BGN
2024-08-31: 1.0000 EUR == 6.2147 BRL
2024-08-31: 1.0000 EUR == 1.5061 CAD
2024-08-31: 1.0000 EUR == 0.9387 CHF
2024-08-31: 1.0000 EUR == 7.8634 CNY
2024-08-31: 1.0000 EUR == 25.1470 CZK
Tests
composer test
Code Quality
composer static-analysis