项目作者: GerardBalaoro

项目描述 :
Library of Congress Cutter Number Generation Library
高级语言: PHP
项目地址: git://github.com/GerardBalaoro/CutterGen.git
创建时间: 2017-11-14T18:49:44Z
项目社区:https://github.com/GerardBalaoro/CutterGen

开源协议:MIT License

下载


CutterGen

Library of Congress Cutter Number Generation Library.

PHP from Packagist
GitHub
Packagist Version
CircleCI

This package follows the specifications presented on the
Classification and Shelflisting Manual Instruction Sheet G63.

See demonstration on PHP Sandbox.

Installation

  1. composer require gerardbalaoro/cuttergen

Basic Usage

  1. /**
  2. * Initialize CutterGen instance, pass default expansion length (optional)
  3. * - $length = 0 : no expansion
  4. * - $length = -1 : expand all characters
  5. */
  6. $cutter = new CutterGen\CutterGen(1);
  7. /**
  8. * Can also set default expansion length using `setLength`
  9. */
  10. $cutter->setLength(2);
  11. /**
  12. * Generate cutter number (Prints: S658)
  13. */
  14. echo $cutter->generate('Smith');
  15. /**
  16. * Can also pass length (Prints: S65)
  17. */
  18. echo $cutter->generate('Smith', 1);

Handling Qa - Qt Initials

For initials Qa-Qt, use numbers 2-29

By default, the package assigns values to a character by its order in the English alpabeth, starting at 2.
To customize, simple pass a callable object to the setHandlder() method.

  1. $cutter = new CutterGen\CutterGen();
  2. $cutter->setHandler('qa-qt', function($char) {
  3. if ($char == 'a') {
  4. return '5';
  5. }
  6. ...
  7. });
  8. // Prints: Q55
  9. echo $cutter->generate('Qaldor')

Reference