cable8mm/n-format
最新稳定版本:v1.3.0
Composer 安装命令:
composer require cable8mm/n-format
包简介
Small NumberFormatter Extension Library
README 文档
README
PHP already includes NumberFormat classes and functions, but they may not be available for some countries like Korea and Japan. Therefore, we provide a small wrapper library to extend NumberFormat, similar to how Carbon extends DateTime. Additionally, some additional functions have been provided.
If you have used Laravel, you could use NFormatHelper helper class. Refer to the Usage Laravel Helper section.
We have provided the API Documentation on the web. For more information, please visit https://www.palgle.com/n-format/ ❤️
Install
composer require cable8mm/n-format
Usage
General:
print NFormat::currency(358762); // default locale = 'ko_KR' currency = 'KRW' //=> ₩358,762
print NFormat::spellOut(5); // default locale = 'ko_KR' currency = 'KRW' //=> 오
NFormat::$locale = 'ja_JP'; print NFormat::spellOut(5); //=> 五
print NFormat::decimal(12346); //=> 12,346 print NFormat::percent(12346); //=> 1,234,600% print NFormat::rawPercent(12346); //=> 12,346%
New special method ordinalSpellOut and currencySpellOut(only ko_KR):
print NFormat::ordinalSpellOut(10); //=> 열번째 print NFormat::currencySpellOut(12346); //=> 12,346 원
You can also use price() and smartPrice() to calculate the price for customers.
print NFormat::price(12346, -2); //=> 12300 print NFormat::price(12346.23, 1); //=> 12346.20 print NFormat::smartPrice(12346); //=> 12300 print NFormat::smartPrice(123467); //=> 123000 print NFormat::smartPrice(1234678); //=> 1230000 print NFormat::smartPrice(12346432); //=> 12350000 print NFormat::smartPrice(3212343232); //=> 3212340000
Laravel Helper
You can utilize this in Laravel Blade without any need for installation:
{{ NFormatHelper::currency(12346) }}
Formatting
composer lint # Modify all files to comply with the PSR-12. composer inspect # Inspect all files to ensure compliance with PSR-12.
Test
composer test
License
The N-Format is open-sourced software licensed under the MIT license.
统计信息
- 总下载量: 1.03k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-06-15