PHPackages                             lemonade/component\_currency - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. lemonade/component\_currency

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

lemonade/component\_currency
============================

Lemonade Currency Conversion Library provides a reliable PHP solution for converting currencies using the Czech National Bank (CNB) as a primary source. Fully compatible with PHP 8.1 and optimized for static analysis with PHPStan.

v1.2.1(1y ago)220MITPHPPHP &gt;=8.1 &lt;8.5

Since May 31Pushed 1y ago1 watchersCompare

[ Source](https://github.com/johnnyxlemonade/component_currency)[ Packagist](https://packagist.org/packages/lemonade/component_currency)[ RSS](/packages/lemonade-component-currency/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (1)Versions (7)Used By (0)

Lemonade Currency Conversion Library
====================================

[](#lemonade-currency-conversion-library)

[![License](https://camo.githubusercontent.com/f8df3091bbe1149f398a5369b2c39e896766f9f6efba3477c63e9b4aa940ef14/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e)](https://camo.githubusercontent.com/f8df3091bbe1149f398a5369b2c39e896766f9f6efba3477c63e9b4aa940ef14/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e)[![Build Status](https://camo.githubusercontent.com/86fdc76b2f39e0d7318b16ae27da5b8299ba04489c4efed42a7dbb7dc22b728c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6a6f686e6e79786c656d6f6e6164652f636f6d706f6e656e745f63757272656e63792f7068702d63692e796d6c3f6272616e63683d6d6173746572266c6162656c3d6275696c64)](https://camo.githubusercontent.com/86fdc76b2f39e0d7318b16ae27da5b8299ba04489c4efed42a7dbb7dc22b728c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6a6f686e6e79786c656d6f6e6164652f636f6d706f6e656e745f63757272656e63792f7068702d63692e796d6c3f6272616e63683d6d6173746572266c6162656c3d6275696c64)[![PHP Version](https://camo.githubusercontent.com/6518db1335bf20fdff07253dc6d6d0cec955b5fb6a8ef1382ac6d73687ecc07f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344382e312d626c7565)](https://camo.githubusercontent.com/6518db1335bf20fdff07253dc6d6d0cec955b5fb6a8ef1382ac6d73687ecc07f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344382e312d626c7565)[![Packagist Version](https://camo.githubusercontent.com/896f831ba19782569a90d6b5b3e4c0eb42a7664d6e73b589131728e6d1cfa5b3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c656d6f6e6164652f636f6d706f6e656e745f63757272656e6379)](https://camo.githubusercontent.com/896f831ba19782569a90d6b5b3e4c0eb42a7664d6e73b589131728e6d1cfa5b3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c656d6f6e6164652f636f6d706f6e656e745f63757272656e6379)

**Lemonade Currency Conversion Library** provides a general-purpose currency converter using the Czech National Bank (CNB) as the primary data source.

Features
--------

[](#features)

- Supports PHP 8.1+
- Fully typed and optimized for static analysis with PHPStan (Level 10 Strict, Bleeding Edge)
- Provides exchange rates and currency values for supported currencies
- Caches and validates data from the Czech National Bank (CNB)
- Fallback to default values when data is unavailable
- Automatically adjusts to CNB's schedule:
    - Exchange rates are published on working days after 14:30.
    - Before 14:30, the previous day's rates are used as "current".

Supported Data Sources
----------------------

[](#supported-data-sources)

- CNB API

Supported Currencies
--------------------

[](#supported-currencies)

- CZK - Czech Republic
- EUR - Eurozone
- HUF - Hungary
- PLN - Poland
- GBP - Great Britain
- USD - United States

Installation
------------

[](#installation)

Use Composer to install the library:

```
composer require lemonade/currency
```

Usage
-----

[](#usage)

```
use Lemonade\Currency\CurrencyRate;
use Lemonade\Currency\CurrencyMarket;

// Get the ratio of a foreign currency against the local currency (current day)
$currencyRate = CurrencyRate::getRatio(currency: "EUR");

// Get the value of a foreign currency against the local currency
$currencyValue = CurrencyRate::getValue(currency: "USD");

// Access market data for a specific date
$market = new CurrencyMarket(new DateTime('2023-12-01'));
$ratio = $market->getRatio(currency: "EUR");
$value = $market->getValue(currency: "USD");

// Alternatively, specify a date directly in the static methods
$currencyRateForSpecificDate = CurrencyRate::getRatio(currency: "EUR", date: new DateTime('2023-12-01'));
$currencyValueForSpecificDate = CurrencyRate::getValue(currency: "USD", date: new DateTime('2023-12-01'));
```

Configuration
-------------

[](#configuration)

The library dynamically stores data in a project-specific `storage/export/cnb` directory. Ensure this directory is writable.

Advanced Features
-----------------

[](#advanced-features)

- **Static Analysis**: The library is fully compatible with PHPStan Level 10, strict mode, and bleeding edge.
- **Default Values**: Fallback to predefined default values for all currencies when data is unavailable.
- **Extensibility**: Easily extendable for additional data sources or customization.

Testing
-------

[](#testing)

To run unit tests:

```
vendor/bin/phpunit
```

Contributing
------------

[](#contributing)

Feel free to submit issues or create pull requests to improve this library.

License
-------

[](#license)

This library is licensed under the MIT License. See the `LICENSE` file for details.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance39

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity62

Established project with proven stability

 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

Every ~39 days

Recently: every ~11 days

Total

6

Last Release

520d ago

PHP version history (2 changes)v1.0.0PHP &gt;=8.1

v1.1.0PHP &gt;=8.1 &lt;8.5

### Community

Maintainers

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

---

Top Contributors

[![johnnyxlemonade](https://avatars.githubusercontent.com/u/3079458?v=4)](https://github.com/johnnyxlemonade "johnnyxlemonade (23 commits)")

---

Tags

cnbconversion

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/lemonade-component-currency/health.svg)

```
[![Health](https://phpackages.com/badges/lemonade-component-currency/health.svg)](https://phpackages.com/packages/lemonade-component-currency)
```

###  Alternatives

[owenmelbz/laravel-robots-txt

Laravel 5.x helpers for a semi-automated robots.txt and meta tags

151.1k](/packages/owenmelbz-laravel-robots-txt)

PHPackages © 2026

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