PHPackages                             ivashchukk/pkbp-rates - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. ivashchukk/pkbp-rates

ActiveLibrary[HTTP &amp; Networking](/categories/http)

ivashchukk/pkbp-rates
=====================

Framework-agnostic PHP client for PKO BP exchange rate JSON endpoints.

v1.0.0(today)00MITPHPPHP ^8.3CI passing

Since Jul 1Pushed todayCompare

[ Source](https://github.com/ivashchukk/pkbp-rates)[ Packagist](https://packagist.org/packages/ivashchukk/pkbp-rates)[ RSS](/packages/ivashchukk-pkbp-rates/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (8)Versions (2)Used By (0)

PKO BP Rates
============

[](#pko-bp-rates)

[![Tests](https://github.com/ivashchukk/pkbp-rates/actions/workflows/ci.yml/badge.svg)](https://github.com/ivashchukk/pkbp-rates/actions/workflows/ci.yml)[![Coverage](https://camo.githubusercontent.com/bada8c2f36014170f965c6922e7977f3ed0584a9c54ebf3ebb3c758b6d179868/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f7665726167652d504850556e6974253230636c6f7665722d626c7565)](#development)[![Latest Version on Packagist](https://camo.githubusercontent.com/efc7ba48b38387e9be67079b95ab988b473a1c642c95a2c2b6eff3afed198e79/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f69766173686368756b6b2f706b62702d72617465732e737667)](https://packagist.org/packages/ivashchukk/pkbp-rates)[![PHP Version](https://camo.githubusercontent.com/a1d35cd2a5afbd38e64f705c40bf6ddde5238c840a7807d30005108a0b7db146/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f69766173686368756b6b2f706b62702d72617465732e737667)](composer.json)[![License](https://camo.githubusercontent.com/ab81a446f8da70558c49f1a32ee77c2f23fa3d558a121ebcab7b86b413a7481a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f69766173686368756b6b2f706b62702d72617465732e737667)](LICENSE)[![Buy Me a Coffee](https://camo.githubusercontent.com/76aa89df7159dbb0dab6d71d99ef86a87944f882712aa1d65a7946ef1db4a0d6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4275792532306d6525323061253230636f666665652d737570706f72742d79656c6c6f772e737667)](https://buymeacoffee.com/ivashchuk)

Small PHP client for PKO BP exchange rates.

It is built for application code that needs conversions like DKK to EUR or EUR to PLN. Amounts are passed around as integer minor units, so `100_00` means `100.00` for currencies with two decimal places.

Install
-------

[](#install)

```
composer require ivashchukk/pkbp-rates
```

Convert Money
-------------

[](#convert-money)

```
use Ivashchukk\PkbpRates\Currency;
use Ivashchukk\PkbpRates\PkbpRatesClient;

$client = PkbpRatesClient::create();

$conversion = $client->convert(
    10_000,          // 100.00 DKK
    Currency::DKK,
    Currency::EUR,
);

echo $conversion->source->decimal(); // 100.00
echo $conversion->target->decimal(); // 13.21
echo $conversion->rate;              // EUR per 1 DKK, as a decimal string
```

The result is rounded to the target currency minor unit with half-up rounding.

Use Decimal Input
-----------------

[](#use-decimal-input)

If you receive human-readable amounts from forms or imports, use `Money`:

```
use Ivashchukk\PkbpRates\Currency;
use Ivashchukk\PkbpRates\Dto\Money;

$money = Money::ofDecimal('100.00', Currency::DKK);

$conversion = $client->convertMoney($money, Currency::EUR);

echo $conversion->target->minorAmount; // integer cents
echo $conversion->target->decimal();   // display value
```

`Money::ofMinor(10000, Currency::EUR)` and `Money::ofDecimal('100.00', Currency::EUR)` represent the same amount.

PLN Examples
------------

[](#pln-examples)

```
$eur = $client->convert(10_000, Currency::PLN, Currency::EUR); // 100.00 PLN -> EUR
$pln = $client->convert(1_000, Currency::EUR, Currency::PLN);  // 10.00 EUR -> PLN
```

PLN works like any other currency in the public API.

Rates
-----

[](#rates)

```
$rate = $client->conversionRate(Currency::DKK, Currency::EUR);

echo $rate; // decimal string, not a float
```

For direct PKO BP PLN multipliers:

```
use Ivashchukk\PkbpRates\RateKind;

$eur = $client->sellRate(Currency::EUR);

echo $eur->rate; // PLN per 1 EUR, decimal string

$averageUsd = $client->rate(
    Currency::USD,
    '2024-06-14',
    RateKind::AverageForeign,
);
```

The default is PKO BP `sale_foreign`. PKO values quoted for units like `100 HUF` or `100 JPY` are normalized to a per-unit rate.

Strings Are Accepted
--------------------

[](#strings-are-accepted)

Typed currency constants are usually nicer:

```
$client->convert(10_000, Currency::DKK, Currency::EUR);
```

Strings are useful when the code comes from a request, database, or config:

```
$client->convert(10_000, 'DKK', 'EUR');

$currency = Currency::fromCode('eur'); // Currency::EUR
```

Dates
-----

[](#dates)

```
$conversion = $client->convert(
    10_000,
    Currency::DKK,
    Currency::EUR,
    '2024-06-14',
);
```

Passing `null` as the date means today in `Europe/Warsaw`. If PKO BP has no table for that day, the client looks back up to 10 calendar days.

Error Handling
--------------

[](#error-handling)

```
use Ivashchukk\PkbpRates\Exception\PkbpRatesException;

try {
    $conversion = $client->convert(10_000, Currency::DKK, Currency::EUR);
} catch (PkbpRatesException $exception) {
    // HTTP error, invalid PKO response, missing table, or missing currency.
}
```

Package exceptions:

- `HttpRequestFailedException`
- `InvalidResponseException`
- `TableNotFoundException`
- `CurrencyNotFoundException`
- `RateFieldNotFoundException`

HTTP Client
-----------

[](#http-client)

`PkbpRatesClient::create()` uses Guzzle. To inject your own HTTP stack, pass PSR-18 and PSR-17 implementations:

```
use Ivashchukk\PkbpRates\PkbpRatesClient;

$client = new PkbpRatesClient($psr18Client, $psr17RequestFactory);
```

Development
-----------

[](#development)

```
composer install
composer test
composer analyse
composer cs
```

Generate a local coverage file:

```
vendor/bin/phpunit --coverage-clover coverage.xml
```

Live tests are skipped unless enabled:

```
PKBP_RATES_LIVE=1 vendor/bin/phpunit --group live
```

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance100

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

0d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ffa65756e812f0e343aa59bafda75779768aaf07887ef7a73c88958e0bb42a4f?d=identicon)[ivashchukk](/maintainers/ivashchukk)

---

Top Contributors

[![ivashchukk](https://avatars.githubusercontent.com/u/42264703?v=4)](https://github.com/ivashchukk "ivashchukk (2 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/ivashchukk-pkbp-rates/health.svg)

```
[![Health](https://phpackages.com/badges/ivashchukk-pkbp-rates/health.svg)](https://phpackages.com/packages/ivashchukk-pkbp-rates)
```

###  Alternatives

[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k13](/packages/tempest-framework)[flow-php/flow

PHP ETL - Extract Transform Load - Data processing framework

85036.3k](/packages/flow-php-flow)[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.3k543.5M2.5k](/packages/aws-aws-sdk-php)[guzzlehttp/psr7

PSR-7 message implementation that also provides common utility methods

8.0k1.1B3.9k](/packages/guzzlehttp-psr7)[typo3/cms

TYPO3 CMS is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.

1.2k1.9M122](/packages/typo3-cms)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k656.1k38](/packages/neuron-core-neuron-ai)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
