milantarami/number-to-words 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

milantarami/number-to-words

Composer 安装命令:

composer require milantarami/number-to-words

包简介

A sweet package for converting a number to words that support Nepali & International Numbering System

README 文档

README

Issues Stars

Installation and setup

You can install this package via composer using:

composer require milantarami/number-to-words

The package will automatically register its service provider for laravel 5.5.* and above.
For below version need to register a service provider manually in config/app.php

'providers' => [

    /*
    * Package Service Providers...
    */
    
   MilanTarami\NumberToWordsConverter\NumberToWordsServiceProvider::class         

],

The package will automatically load alias for laravel 5.5.* and above.
For below version need to add alias manually in config/app.php

'aliases' => [
    .
    .
    'NumberToWords' => MilanTarami\NumberToWordsConverter\Facades\NumberToWordsFacade::class,

]

To publish the config file to config/number_to_words.php run:

php artisan vendor:publish --tag=number-to-words-config

This is the default contents of the configuration:

<?php

return [

    /** 
    *  Add a monetary unit notation to response
    * [ true / false ]
    * default = true
    **/

    'monetary_unit_enable' => true,
    
    /** 
    * supported response language 
    * [ English (en) / Nepali [np] ]
    * default = en
    **/

    'lang' => 'en',

    /** 
    * supported Response Type
    * [ 'string', 'array' ]
    * default = string
    **/

    'response_type' => 'string',

    /** 
    * supported numbering systems
    * [ Nepali Numbering System (nns) / International Numbering System (ins) ]
    * default = nns
    **/

    'numbering_system' => 'nns',

    /** 
    * Monetary Units for Nepal [ in English and Nepali ]
    * ex [ 'Dollar', 'Cent ]
    **/
        
    'monetary_unit' => [

        'en' => [ 
            'Rupees', 'Paisa'
        ],
        'np' => [
            'रुपैया', 'पैसा'
        ]
    ],


];

Optional Paramater ( Array - available keys and values)

Key Description Type Avaliable Values Default
monetary_unit_enable Enable / Disable monetary unit in response Boolean true, false true
lang Nepali and English Languages are avaliable String en, np en
response_type Output can be returned in String and Array Format String string, array string
numbering_system Two Numbering System are avaliable are Nepali Numbering System (nns) and International Numbering System (ins) String nns, ins nns
monetary_unit You can setup your custom monetary unit in output by replacing Rupees / Paisa as Dollar / Cent . Array Use custom value as array [ 'Dollar', 'Cent' ] Depends upon language selected

Basic Usage

echo NumberToWords::get(123456789);

//output : Twelve Crore Thirty-four Lakh Fifty-six Thousand Seven Hundred Eighty-nine Rupees and Twelve Paisa

Usage with config as optional paramater

Example 1

$config = [
     'monetary_unit' => [ 'Dollar', 'Cent' ],
     'numbering_system' => 'ins'
 ];
 echo NumberToWords::get(123456789.12, $config);
 
 //output : One Hundred Twenty-three Million Four Hundred Fifty-six Thousand Seven Hundred Eighty-nine Dollar and Twelve Cent
 

Example 2

$config = [
    'monetary_unit' => [ 'Dollar', 'Cent' ],
    'numbering_system' => 'ins',
    'response_type' => 'array'
];

dd(NumberToWords::get(123456789.12, $config));

//output :
array:7 [▼
 "integer" => 123456789
 "integer_in_words" => "One Hundred Twenty-three Million Four Hundred Fifty-six Thousand Seven Hundred Eighty-nine Dollar"
 "point" => 12
 "point_in_words" => "Twelve Cent"
 "original_input" => "123456789.12"
 "formatted_input" => "123,456,789.12"
 "in_words" => "One Hundred Twenty-three Million Four Hundred Fifty-six Thousand Seven Hundred Eighty-nine Dollar and Twelve Cent"
]

milantarami/number-to-words 适用场景与选型建议

milantarami/number-to-words 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7.08k 次下载、GitHub Stars 达 5, 最近一次更新时间为 2019 年 09 月 01 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 milantarami/number-to-words 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 milantarami/number-to-words 我们能提供哪些服务?
定制开发 / 二次开发

基于 milantarami/number-to-words 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 7.08k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 22
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-09-01