Czech National Bank

Contents

Czech National Bank#

This service retrieves the data from the Czech National Bank.

Installation#

Install the service:

composer require peso/cnb-service

Install the service with all recommended dependencies:

composer require peso/cnb-service php-http/discovery guzzlehttp/guzzle symfony/cache

Usage#

Changed in version 1.1: CzechNationalBankService -> CzechNationalBank\CentralBankFixingService

Added in version 1.1: OtherCurrenciesService

The package provides 2 Service objects:

  • \Peso\Services\CzechNationalBank\CentralBankFixingService: Central bank exchange rate fixing data (daily rates)

  • \Peso\Services\CzechNationalBank\OtherCurrenciesService: FX rates of other currencies (monthly rates)

Example:

<?php

use Peso\Peso\CurrencyConverter;
use Peso\Services\CzechNationalBank\CentralBankFixingService;
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
use Symfony\Component\Cache\Psr16Cache;

$cache = new Psr16Cache(new FilesystemAdapter(directory: __DIR__ . '/cache'));
$service = new CentralBankFixingService($cache);
$converter = new CurrencyConverter($service);

// 310812.50 as of 2025-06-23
echo $converter->convert('12500', 'EUR', 'CZK', 2), PHP_EOL;

// reversible (wraps service with ReversibleService)

$service = CentralBankFixingService::reversible($cache);
$converter = new CurrencyConverter($service);

// 502.71 as of 2025-06-23
echo $converter->convert('12500', 'CZK', 'EUR', 2), PHP_EOL;

Note

Reversible Factory emits non-precise services that can only be used in informational purposes.