tiny-blocks / currency
Models ISO-4217 currencies as a PHP enum, with per-currency fraction digit resolution.
2.3.1
2026-04-21 23:20 UTC
Requires
- php: ^8.5
Requires (Dev)
- ergebnis/composer-normalize: ^2.51
- infection/infection: ^0.32
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^13.1
- squizlabs/php_codesniffer: ^4.0
README
Overview
Models ISO-4217 currencies as a PHP enum, covering all standard currency codes with their correct number of fraction digits. Resolves edge cases such as zero-decimal currencies (JPY, KRW), three-decimal currencies (BHD, KWD), and four-decimal currencies (CLF, UYW). Backed by a native PHP enum for zero-overhead comparison and type safety.
Installation
composer require tiny-blocks/currency
How to use
The library exposes a concrete implementation through the Currency enum. Besides, the alphabetic code, you can
get the default amount fraction digits for the respective currency.
$currency = Currency::USD; $currency->name; # USD $currency->value; # USD $currency->getFractionDigits(); # 2
License
Currency is licensed under MIT.
Contributing
Please follow the contributing guidelines to contribute to the project.