Helper Functions

ramsey/uuid additionally provides the following helper functions, which return only the string standard representation of a UUID.

Ramsey\Uuid\v1([$node[, $clockSeq]])

Generates a string standard representation of a version 1, time-based UUID.

Parameters
  • $node (Ramsey\Uuid\Type\Hexadecimal|null) – An optional hexadecimal node to use

  • $clockSeq (int|null) – An optional clock sequence to use

Returns

A string standard representation of a version 1 UUID

Return type

string

Ramsey\Uuid\v2($localDomain[, $localIdentifier[, $node[, $clockSeq]]])

Generates a string standard representation of a version 2, DCE Security UUID.

Parameters
  • $localDomain (int) – The local domain to use (one of Uuid::DCE_DOMAIN_PERSON, Uuid::DCE_DOMAIN_GROUP, or Uuid::DCE_DOMAIN_ORG)

  • $localIdentifier (Ramsey\Uuid\Type\Integer|null) – A local identifier for the domain (defaults to system UID or GID for person or group)

  • $node (Ramsey\Uuid\Type\Hexadecimal|null) – An optional hexadecimal node to use

  • $clockSeq (int|null) – An optional clock sequence to use

Returns

A string standard representation of a version 2 UUID

Return type

string

Ramsey\Uuid\v3($ns, $name)

Generates a string standard representation of a version 3, name-based (MD5) UUID.

Parameters
  • $ns (Ramsey\Uuid\UuidInterface|string) – The namespace for this identifier

  • $name (string) – The name from which to generate an identifier

Returns

A string standard representation of a version 3 UUID

Return type

string

Ramsey\Uuid\v4()

Generates a string standard representation of a version 4, random UUID.

Returns

A string standard representation of a version 4 UUID

Return type

string

Ramsey\Uuid\v5($ns, $name)

Generates a string standard representation of a version 5, name-based (SHA-1) UUID.

Parameters
  • $ns (Ramsey\Uuid\UuidInterface|string) – The namespace for this identifier

  • $name (string) – The name from which to generate an identifier

Returns

A string standard representation of a version 5 UUID

Return type

string

Ramsey\Uuid\v6([$node[, $clockSeq]])

Generates a string standard representation of a version 6, ordered-time UUID.

Parameters
  • $node (Ramsey\Uuid\Type\Hexadecimal|null) – An optional hexadecimal node to use

  • $clockSeq (int|null) – An optional clock sequence to use

Returns

A string standard representation of a version 6 UUID

Return type

string