putheakhem/khmer-number-to-text
最新稳定版本:v1.0.1
Composer 安装命令:
composer require putheakhem/khmer-number-to-text
包简介
Convert Khmer numbers to Khmer text representation
README 文档
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.
🇰🇭 Stand with Cambodia • កម្ពុជា
🕊️ Cambodia Needs Peace 🕊️
With heavy hearts, we stand with our brave soldiers defending Cambodia’s land and dignity.
We seek no conflict—only peace, justice, and respect for our sovereignty.
🙏 កម្ពុជាត្រូវការសន្តិភាព • Together to protect Cambodia’s sovereignty.
📦 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
统计信息
- 总下载量: 493
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-05-19