Uuid

Ramsey\Uuid\Uuid provides static methods for the most common functionality for generating and working with UUIDs. It also provides constants used throughout the ramsey/uuid library.

class Ramsey\Uuid\Uuid
constant UUID_TYPE_TIME

Version 1: Gregorian Time UUID.

constant UUID_TYPE_DCE_SECURITY

Version 2: DCE Security UUID.

constant UUID_TYPE_HASH_MD5

Version 3: Name-based (MD5) UUID.

constant UUID_TYPE_RANDOM

Version 4: Random UUID.

constant UUID_TYPE_HASH_SHA1

Version 5: Name-based (SHA-1) UUID.

constant UUID_TYPE_REORDERED_TIME

Version 6: Reordered Gregorian Time UUID.

constant UUID_TYPE_PEABODY

Deprecated. Use Uuid::UUID_TYPE_REORDERED_TIME instead.

constant UUID_TYPE_UNIX_TIME

Version 7: Unix Epoch Time UUID.

constant UUID_TYPE_CUSTOM

Version 8: Custom Format UUID.

constant NAMESPACE_DNS

The name string is a fully-qualified domain name.

constant NAMESPACE_URL

The name string is a URL.

constant NAMESPACE_OID

The name string is an ISO object identifier (OID).

constant NAMESPACE_X500

The name string is an X.500 DN in DER or a text output format.

constant NIL

The nil UUID is a special form of UUID that is specified to have all 128 bits set to zero.

constant DCE_DOMAIN_PERSON

DCE Security principal (person) domain.

constant DCE_DOMAIN_GROUP

DCE Security group domain.

constant DCE_DOMAIN_ORG

DCE Security organization domain.

constant RESERVED_NCS

Variant identifier: reserved, NCS backward compatibility.

constant RFC_4122

An alias for Uuid::RFC_9562.

constant RFC_9562

Variant identifier: the UUID layout specified in RFC 9562 (formerly RFC 4122).

constant RESERVED_MICROSOFT

Variant identifier: reserved, Microsoft Corporation backward compatibility.

constant RESERVED_FUTURE

Variant identifier: reserved for future definition.

static uuid1([$node[, $clockSeq]])

Generates a version 1, Gregorian time UUID. See Version 1: Gregorian Time.

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

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

Returns:

A version 1 UUID

Return type:

Ramsey\Uuid\Rfc4122\UuidV1

static uuid2($localDomain[, $localIdentifier[, $node[, $clockSeq]]])

Generates a version 2, DCE Security UUID. See Version 2: DCE Security.

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 version 2 UUID

Return type:

Ramsey\Uuid\Rfc4122\UuidV2

static uuid3($ns, $name)

Generates a version 3, name-based (MD5) UUID. See Version 3: Name-based (MD5).

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

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

Returns:

A version 3 UUID

Return type:

Ramsey\Uuid\Rfc4122\UuidV3

static uuid4

Generates a version 4, random UUID. See Version 4: Random.

Returns:

A version 4 UUID

Return type:

Ramsey\Uuid\Rfc4122\UuidV4

static uuid5($ns, $name)

Generates a version 5, name-based (SHA-1) UUID. See Version 5: Name-based (SHA-1).

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

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

Returns:

A version 5 UUID

Return type:

Ramsey\Uuid\Rfc4122\UuidV5

static uuid6([$node[, $clockSeq]])

Generates a version 6, reordered Gregorian time UUID. See Version 6: Reordered Gregorian Time.

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

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

Returns:

A version 6 UUID

Return type:

Ramsey\Uuid\Rfc4122\UuidV6

static uuid7([$dateTime])

Generates a version 7, Unix Epoch time UUID. See Version 7: Unix Epoch Time.

Parameters:
  • $dateTime (DateTimeInterface|null) – The date from which to create the UUID instance

Returns:

A version 7 UUID

Return type:

Ramsey\Uuid\Rfc4122\UuidV7

static uuid8($bytes)

Generates a version 8, implementation-specific, custom format UUID. See Version 8: Custom Format.

Parameters:
  • $bytes (string) – A 16-byte octet string. This is an open blob of data that you may fill with 128 bits of information. Be aware, however, bits 48 through 51 will be replaced with the UUID version field, and bits 64 and 65 will be replaced with the UUID variant. You MUST NOT rely on these bits for your application needs.

Returns:

A version 8 UUID

Return type:

Ramsey\Uuid\Rfc4122\UuidV8

static fromString($uuid)

Creates an instance of UuidInterface from the string standard representation.

Parameters:
  • $uuid (string) – The string standard representation of a UUID

Return type:

Ramsey\Uuid\UuidInterface

static fromBytes($bytes)

Creates an instance of UuidInterface from a 16-byte string.

Parameters:
  • $bytes (string) – A 16-byte binary string representation of a UUID

Return type:

Ramsey\Uuid\UuidInterface

static fromInteger($integer)

Creates an instance of UuidInterface from a 128-bit string integer.

Parameters:
  • $integer (string) – A 128-bit string integer representation of a UUID

Return type:

Ramsey\Uuid\UuidInterface

static fromDateTime($dateTime[, $node[, $clockSeq]])

Creates a version 1 UUID instance from a DateTimeInterface instance.

Parameters:
  • $dateTime (DateTimeInterface) – The date from which to create the UUID instance

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

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

Returns:

A version 1 UUID

Return type:

Ramsey\Uuid\Rfc4122\UuidV1

static isValid($uuid)

Validates the string standard representation of a UUID.

Parameters:
  • $uuid (string) – The string standard representation of a UUID

Return type:

bool

static setFactory($factory)

Sets the factory used to create UUIDs.

Parameters:
Return type:

void