putheakhem/khmer-number-to-text

Convert Khmer numbers to Khmer text representation

v1.0.1 2025-05-19 06:03 UTC

This package is auto-updated.

Last update: 2025-05-26 11:08:21 UTC


README

Latest Stable Version Total Downloads License

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 β†’ αž˜αž½αž™αž›αžΆαž“αž–αžΈαžšαžšαž™αžŸαžΆαž˜αžŸαž·αž”αž”αŸ’αžšαžΆαŸ†αž”αž½αž“)
  • βœ… 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:

  1. Fork the repository
  2. Create a new branch (git checkout -b feature/YourFeature)
  3. Make your changes
  4. Commit your changes (git commit -m 'Add some feature')
  5. Push to the branch (git push origin feature/YourFeature)
  6. Create a new Pull Request
  7. 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