2017 © Pedro Peláez
 

library sequence

A simple sequence generator

image

griffins/sequence

A simple sequence generator

  • Sunday, February 4, 2018
  • by griffins
  • Repository
  • 1 Watchers
  • 0 Stars
  • 400 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 7 % Grown

The README.md

sequence

A simple sequence generator, (*1)

Build Status, (*2)

installation

composer require griffins/sequence, (*3)

basics

This doc assumes you are autoloading the library via composer., (*4)


$allowedChars = 'ABCDEF0123456789'; //the only argument is an optional character dictonary, if not specified the default one is used. (0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ) $sequence = \Sequence\Factory::create($allowedChars); echo $sequence->next('<yyyy>/????');

Prints 2018/0001, (*5)

<yyyy>, <mm>, <dd> are place holders for the current year,month and day respectively., (*6)


$sequence->next('<yyyy>/????',null,'2018/AAAA')

Prints 2018/AAAB, (*7)

The second argument is a callback that returns true or false to reject the generated sequence, when its returns false it causes a new sequence to be generated till the callback is satisfied or an overflow occours. For example trying to increment 9999 and the format used is limited to 4 characters., (*8)

The smart search optimizes usage of the callback by using binary search to boost perfomance., (*9)

A good usage will be, (*10)


$sequence = \Sequence\Factory::create(); $id = $sequence->next('<yyyy>/????', function($id){ //check if its exits in a dataset, if($exists){ return true; }else{ // looks like we found a valid id return false; } }); // now use the id generated echo $id;

The Versions

04/02 2018

dev-master

9999999-dev

A simple sequence generator

  Sources   Download

MIT

The Development Requires

by Griffins Oringo

04/02 2018

1.0.1

1.0.1.0

A simple sequence generator

  Sources   Download

MIT

The Development Requires

by Griffins Oringo

30/07 2017

1.0.0

1.0.0.0

A simple sequence generator

  Sources   Download

MIT

The Development Requires

by Griffins Oringo