putheakhem / khmer-number-to-text
Convert Khmer numbers to Khmer text representation
Requires
- php: ^8.2
Requires (Dev)
- phpunit/phpunit: ^10
This package is auto-updated.
Last update: 2025-05-26 11:08:21 UTC
README
Khmer Number To Text
Convert Arabic or Khmer digit numbers into Khmer written text format (spoken form), suitable for invoices, financial documents, education, and legal reporting in the Khmer language.
π¦ Installation
composer require putheakhem/khmer-number-to-text
For local development, use a path-based repository in your Laravel project.
π Features
-
β Supports both Arabic (
1234
) and Khmer (α‘α’α£α€
) digit inputs -
β Outputs proper Khmer number words (e.g.,
1234 β αα½αααΆααααΈαααααΆααα·αααααΆααα½α
) -
β Proper handling of:
- Single digits (
6 β ααααΆααα½α
) - Tens (
40 β αααα·α
) - Hundreds, Thousands, Millions (
1234567 β αα½αααΆαααΈαααααΆααα·αααααΆααα½α
)
- Single digits (
-
β Laravel Facade support:
KhmerNumber::toText(1234)
π§ Usage
Basic Example
use Putheakhem\KhmerNumberToText\Facades\KhmerNumber; echo KhmerNumber::toText(1234); // αα½αααΆααααΈαααααΆααα·αααααΆααα½α echo KhmerNumber::toText('α¦α§α¨α©'); // ααααΆααα½αααΆααααααΆαααΈααααααααα·αααααΆααα½α...
Helper
If you prefer, you can use the global helper function:
echo khmer_number_to_text(2025); // ααΈαααΆααααααααααΆα echo khmer_number_to_text('α‘α’α£α€'); // αα½αααΆααααΈαααααΆααα·αααααΆααα½α
π Internals
This package relies on:
-
KhmerNumberConstants
β a centralized definition of:- Khmer digit word mappings
- Tens word patterns (e.g.,
60 β α α»ααα·α
) - Large unit labels (
ααΆα
,ααΆαα
,αα
)
-
Recursive
convertNumber()
logic to handle number decomposition -
Laravel Facade binding via
KhmerNumber
π οΈ Contributing
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a new branch (
git checkout -b feature/YourFeature
) - Make your changes
- Commit your changes (
git commit -m 'Add some feature'
) - Push to the branch (
git push origin feature/YourFeature
) - Create a new Pull Request
- Ensure your code adheres to the coding standards and passes all tests
Security Vulnerabilities
If you discover a security vulnerability within this package, please send an e-mail to puthea.khem at gmail.com. All security vulnerabilities will be promptly addressed.
Support Me
If you find this package useful, consider supporting my work:
π License
The MIT License (MIT). Please see License File for more information.
Built with β€οΈ by Puthea khem