2017 © Pedro Peláez
 

library php-shorthand

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

image

kamranahmedse/php-shorthand

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

  • Wednesday, September 21, 2016
  • by kamranahmedse
  • Repository
  • 2 Watchers
  • 17 Stars
  • 65 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 3 Versions
  • 8 % Grown

The README.md

php-shorthand

Build Status Code Coverage Latest Stable Version, (*1)

Calculate unique shorthands for a given set of strings, (*2)

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

Installation

Use the following command to install via composer, (*4)

composer require kamranahmedse/php-shorthand

For further details you can find the package at Packagist., (*5)

Usage

Instantiate the Shorthand class while passing the words for which you want the shorthands, (*6)

// 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, (*7)

// 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., (*8)

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, (*9)

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

Contribution

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

License

MIT © Kamran Ahmed, (*11)

The Versions

21/09 2016

dev-master

9999999-dev https://github.com/kamranahmedse/php-abbrev

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

  Sources   Download

MIT

The Development Requires

shorthand abbrev ruby-abbrev abbreviations php-abbrev php-shorthand

21/09 2016

1.0.1

1.0.1.0 https://github.com/kamranahmedse/php-abbrev

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

  Sources   Download

MIT

The Development Requires

shorthand abbrev ruby-abbrev abbreviations php-abbrev php-shorthand

21/09 2016

1.0.0

1.0.0.0 https://github.com/kamranahmedse/php-abbrev

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

  Sources   Download

MIT

The Development Requires

abbrev ruby-abbrev abbreviations php-abbrev