kamranahmedse/php-shorthand 问题修复 & 功能扩展

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

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

kamranahmedse/php-shorthand

Composer 安装命令:

composer require kamranahmedse/php-shorthand

包简介

Calculate the set of unique abbreviations for a given set of strings.

README 文档

README

Build Status Code Coverage Latest Stable Version

Calculate unique shorthands for a given set of strings

Inspired by ruby's abbrev module, it let's you calculate the unique set of shorthands for the given set of words.

Installation

Use the following command to install via composer

composer require kamranahmedse/php-shorthand

For further details you can find the package at Packagist.

Usage

Instantiate the Shorthand class while passing the words for which you want the shorthands

// Introduce the class into your scope
use KamranAhmed\Shorthand\Shorthand;

$shorthand = new Shorthand([
    'crore',
    'create',
]);

$shorthands = $shorthand->generate();

It will return an associative array with the key set to the shorthand keyword and value set to the actual word that it refers to

// Shorthands for the above example
[
    'cre'    => 'create',
    'crea'   => 'create',
    'creat'  => 'create',
    'create' => 'create',
    'cro'    => 'crore',
    'cror'   => 'crore',
    'crore'  => 'crore',
],

Usage Scenarios

It can come quite handy when writing command line script that takes a number of options and the user may enter the options shorthand or maybe other cases where you want to be able to accept shorthands.

For example, in a script that accepts the options ['delete', 'create', 'update'], in your script, it can let you infer from the option that user wanted even when they typed a shorthand as long as it is unambiguous

$ shorthand cr   # create
$ shorthand d    # delete
$ shorthand upd  # update

Contribution

Feel free to fork, enhance, open issues, create pull requests or spread the word.

License

MIT © Kamran Ahmed

统计信息

  • 总下载量: 113
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 26
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 26
  • Watchers: 2
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-09-21

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固