Uuid

RamseyUuidUuid 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: Time-based 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_PEABODY

Version 6: Ordered-Time 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

Variant identifier: the UUID layout specified in 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, time-based UUID. See Version 1: Time-based.

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, ordered-time UUID. See Version 6: Ordered-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\Nonstandard\UuidV6

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