定制 fzaffa/baseconverter 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

fzaffa/baseconverter

Composer 安装命令:

composer require fzaffa/baseconverter

包简介

Converts base 10 numbers to any set of characters provided, for example an [a-zA-Z] range.

README 文档

README

#BaseConverter The purpose of this library is to convert decimal numbers to higher bases represented only by alphabet characters to render them easier to remember and easier on the eyes for permalinks and similar applications.

##Installation

    $ composer require fzaffa/baseconverter
    {
        "require": {
            "fzaffa/baseconverter": "dev-master"
        }
    }

##Usage

    use Fzaffa\BaseConverter\BaseConverter;
    use Fzaffa\BaseConverter\ConverterRangeTypes;

    require "vendor/autoload.php"

    $converter = new BaseConverter(ConverterRangeTypes::ALPHA_ULCASE);

    echo $converter->convert(34523) //Outputs: mNV

    echo $converter->convert("mNV") //Outputs: 34523

The convert() method will automatically get the type of the argument, if it is numeric (also a string containing only numbers work) it will convert to a string, if it's a string it will convert to decimal. To force one or the other use convertFromStringToInt or convertFromIntToString.

The provided ranges are:

  • ConverterRangeTypes::ALPHA_LCASE for [a-z]
  • ConverterRangeTypes::ALPHA_UCASE for [A-Z]
  • ConverterRangeTypes::ALPHA_ULCASE for [a-zA-Z]

You can pass in any array of chars that will be used in lieu of their decimal representation (eg. 12 will be the 12th element of the array).

##Notes Will add tests soon.

##Todo

  • Handle cases where the target base is less than 10
  • Write unit tests

##License MIT

统计信息

  • 总下载量: 6.1k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-08-13