interface UuidFactoryInterface (View source)

UuidFactoryInterface defines common functionality all UuidFactory instances must implement

Methods

uuid1(int|string $node = null, int $clockSeq = null)

Generate a version 1 UUID from a host ID, sequence number, and the current time.

uuid3(string $ns, string $name)

Generate a version 3 UUID based on the MD5 hash of a namespace identifier (which is a UUID) and a name (which is a string).

uuid4()

Generate a version 4 (random) UUID.

uuid5(string $ns, string $name)

Generate a version 5 UUID based on the SHA-1 hash of a namespace identifier (which is a UUID) and a name (which is a string).

fromBytes(string $bytes)

Creates a UUID from a byte string.

fromString(string $uuid)

Creates a UUID from the string standard representation

fromInteger(mixed $integer)

Creates a Uuid from an integer representation

Details

UuidInterface uuid1(int|string $node = null, int $clockSeq = null)

Generate a version 1 UUID from a host ID, sequence number, and the current time.

Parameters

int|string $node A 48-bit number representing the hardware address This number may be represented as an integer or a hexadecimal string.
int $clockSeq A 14-bit number used to help avoid duplicates that could arise when the clock is set backwards in time or if the node ID changes.

Return Value

UuidInterface

UuidInterface uuid3(string $ns, string $name)

Generate a version 3 UUID based on the MD5 hash of a namespace identifier (which is a UUID) and a name (which is a string).

Parameters

string $ns The UUID namespace in which to create the named UUID
string $name The name to create a UUID for

Return Value

UuidInterface

UuidInterface uuid4()

Generate a version 4 (random) UUID.

Return Value

UuidInterface

UuidInterface uuid5(string $ns, string $name)

Generate a version 5 UUID based on the SHA-1 hash of a namespace identifier (which is a UUID) and a name (which is a string).

Parameters

string $ns The UUID namespace in which to create the named UUID
string $name The name to create a UUID for

Return Value

UuidInterface

UuidInterface fromBytes(string $bytes)

Creates a UUID from a byte string.

Parameters

string $bytes A 16-byte string representation of a UUID

Return Value

UuidInterface

UuidInterface fromString(string $uuid)

Creates a UUID from the string standard representation

Parameters

string $uuid A string representation of a UUID

Return Value

UuidInterface

UuidInterface fromInteger(mixed $integer)

Creates a Uuid from an integer representation

The integer representation may be a real integer, a string integer, or an integer representation supported by a configured number converter.

Parameters

mixed $integer The integer to use when creating a Uuid from an integer; may be of any type understood by the configured number converter

Return Value

UuidInterface