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 string|null $collection from IncrementGenerator
protected string|null $key from IncrementGenerator
protected int $startingId from IncrementGenerator
protected int|null $pad
protected bool $awkwardSafeMode
protected string $chars
protected string $awkwardSafeChars

Methods

mixed
generate(DocumentManager $dm, object $document)

No description

setCollection(string $collection)

No description

setKey(string $key)

No description

setStartingId(int $startingId)

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(string $collection)

Parameters

string $collection

setKey(string $key)

Parameters

string $key

setStartingId(int $startingId)

Parameters

int $startingId

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