UUID
in package
UUID Generator Class provides static methods for creating or validating UUIDs.
Tags
Table of Contents
Constants
- UUID_LENGTH_MAX = self::UUID_LENGTH_MIN + 6
- UUID_LENGTH_MIN = 8 + 4 + 4 + 4 + 12
Methods
- is_valid() : mixed
- v4() : string
- Creates a v4 UUID
- validate() : string|null
- Validates a given UUID and makes sure the returned value is a normalized UUID or null.
Constants
UUID_LENGTH_MAX
public
mixed
UUID_LENGTH_MAX
= self::UUID_LENGTH_MIN + 6
UUID_LENGTH_MIN
public
mixed
UUID_LENGTH_MIN
= 8 + 4 + 4 + 4 + 12
Methods
is_valid()
public
static is_valid(mixed $uuid) : mixed
Parameters
- $uuid : mixed
Tags
v4()
Creates a v4 UUID
public
static v4() : string
Tags
Return values
stringvalidate()
Validates a given UUID and makes sure the returned value is a normalized UUID or null.
public
static validate(string|mixed $uuid[, bool $withDash = true ][, bool|null $caseToLower = true ][, bool|null $withCurlyBrackets = false ]) : string|null
Normalized means: with now curly brackets but with dashes: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx, unless configured with additional parameters. See parameter description.
Parameters
- $uuid : string|mixed
- $withDash : bool = true
-
Dashes will be true = ensured between blocks: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx (default) false = removed: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx null = untouched
- $caseToLower : bool|null = true
-
Character chase will be true = lowercase (default) false = uppercase null = unchanged
- $withCurlyBrackets : bool|null = false
-
Embracing curly brackets will be true = ensured: {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX} false = removed: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX (default) null = untouched
Tags
Return values
string|null —Valid, normalized GUID or null on invalid input