class AlnumGenerator extends IncrementGenerator (View source)

AlnumGenerator is responsible for generating cased alpha-numeric unique identifiers.

It extends IncrementGenerator in order to ensure uniqueness even with short strings.

"Awkward safe mode" avoids combinations that results in 'dirty' words by removing the vowels from chars index

A minimum identifier length can be enforced by setting a numeric value to the "pad" option (with only 6 chars you will have more than 56 billion unique id's, 15 billion in 'awkward safe mode')

The character set used for ID generation can be explicitly set with the "chars" option (e.g. base36, etc.)

Properties

protected $collection from IncrementGenerator
protected $key from IncrementGenerator
protected $pad
protected $awkwardSafeMode
protected $chars
protected $awkwardSafeChars

Methods

mixed
generate(DocumentManager $dm, object $document)

No description

setCollection($collection)

No description

setKey($key)

No description

setPad(int $pad)

Set padding on generated id

setAwkwardSafeMode(bool $awkwardSafeMode = false)

Enable awkwardSafeMode character set

setChars(string $chars)

Set the character set used for ID generation

Details

mixed generate(DocumentManager $dm, object $document)

Parameters

DocumentManager $dm
object $document

Return Value

mixed

setCollection($collection)

Parameters

$collection

setKey($key)

Parameters

$key

setPad(int $pad)

Set padding on generated id

Parameters

int $pad

setAwkwardSafeMode(bool $awkwardSafeMode = false)

Enable awkwardSafeMode character set

Parameters

bool $awkwardSafeMode

setChars(string $chars)

Set the character set used for ID generation

Parameters

string $chars ID character set