Skip to content

UuidFactory

Properties

codec

private \Ramsey\Uuid\Codec\CodecInterface $codec

dceSecurityGenerator

private \Ramsey\Uuid\Generator\DceSecurityGeneratorInterface $dceSecurityGenerator

nameGenerator

private \Ramsey\Uuid\Generator\NameGeneratorInterface $nameGenerator

nodeProvider

private \Ramsey\Uuid\Provider\NodeProviderInterface $nodeProvider

numberConverter

private \Ramsey\Uuid\Converter\NumberConverterInterface $numberConverter

randomGenerator

private \Ramsey\Uuid\Generator\RandomGeneratorInterface $randomGenerator

timeConverter

private \Ramsey\Uuid\Converter\TimeConverterInterface $timeConverter

timeGenerator

private \Ramsey\Uuid\Generator\TimeGeneratorInterface $timeGenerator

unixTimeGenerator

private \Ramsey\Uuid\Generator\TimeGeneratorInterface $unixTimeGenerator

uuidBuilder

private \Ramsey\Uuid\Builder\UuidBuilderInterface $uuidBuilder

validator

private \Ramsey\Uuid\Validator\ValidatorInterface $validator

isDefaultFeatureSet

private bool $isDefaultFeatureSet

Methods

__construct

public __construct(\Ramsey\Uuid\FeatureSet|null $features = null): mixed

Parameters:

Parameter Type Description
$features \Ramsey\Uuid\FeatureSet|null A set of available features in the current environment

getCodec

Returns the codec used by this factory

public getCodec(): \Ramsey\Uuid\Codec\CodecInterface

setCodec

Sets the codec to use for this factory

public setCodec(\Ramsey\Uuid\Codec\CodecInterface $codec): void

Parameters:

Parameter Type Description
$codec \Ramsey\Uuid\Codec\CodecInterface A UUID encoder-decoder

getNameGenerator

Returns the name generator used by this factory

public getNameGenerator(): \Ramsey\Uuid\Generator\NameGeneratorInterface

setNameGenerator

Sets the name generator to use for this factory

public setNameGenerator(\Ramsey\Uuid\Generator\NameGeneratorInterface $nameGenerator): void

Parameters:

Parameter Type Description
$nameGenerator \Ramsey\Uuid\Generator\NameGeneratorInterface A generator to generate
binary data, based on a namespace and name

getNodeProvider

Returns the node provider used by this factory

public getNodeProvider(): \Ramsey\Uuid\Provider\NodeProviderInterface

getRandomGenerator

Returns the random generator used by this factory

public getRandomGenerator(): \Ramsey\Uuid\Generator\RandomGeneratorInterface

getTimeGenerator

Returns the time generator used by this factory

public getTimeGenerator(): \Ramsey\Uuid\Generator\TimeGeneratorInterface

setTimeGenerator

Sets the time generator to use for this factory

public setTimeGenerator(\Ramsey\Uuid\Generator\TimeGeneratorInterface $generator): void

Parameters:

Parameter Type Description
$generator \Ramsey\Uuid\Generator\TimeGeneratorInterface A generator to generate binary
data, based on the time

getDceSecurityGenerator

Returns the DCE Security generator used by this factory

public getDceSecurityGenerator(): \Ramsey\Uuid\Generator\DceSecurityGeneratorInterface

setDceSecurityGenerator

Sets the DCE Security generator to use for this factory

public setDceSecurityGenerator(\Ramsey\Uuid\Generator\DceSecurityGeneratorInterface $generator): void

Parameters:

Parameter Type Description
$generator \Ramsey\Uuid\Generator\DceSecurityGeneratorInterface A generator to generate
binary data, based on a local domain and local identifier

getNumberConverter

Returns the number converter used by this factory

public getNumberConverter(): \Ramsey\Uuid\Converter\NumberConverterInterface

setRandomGenerator

Sets the random generator to use for this factory

public setRandomGenerator(\Ramsey\Uuid\Generator\RandomGeneratorInterface $generator): void

Parameters:

Parameter Type Description
$generator \Ramsey\Uuid\Generator\RandomGeneratorInterface A generator to generate binary
data, based on some random input

setNumberConverter

Sets the number converter to use for this factory

public setNumberConverter(\Ramsey\Uuid\Converter\NumberConverterInterface $converter): void

Parameters:

Parameter Type Description
$converter \Ramsey\Uuid\Converter\NumberConverterInterface A converter to use for working
with large integers (i.e. integers greater than PHP_INT_MAX)

getUuidBuilder

Returns the UUID builder used by this factory

public getUuidBuilder(): \Ramsey\Uuid\Builder\UuidBuilderInterface

setUuidBuilder

Sets the UUID builder to use for this factory

public setUuidBuilder(\Ramsey\Uuid\Builder\UuidBuilderInterface $builder): void

Parameters:

Parameter Type Description
$builder \Ramsey\Uuid\Builder\UuidBuilderInterface A builder for constructing instances
of UuidInterface

getValidator

Returns the validator to use for the factory

public getValidator(): \Ramsey\Uuid\Validator\ValidatorInterface

setValidator

Sets the validator to use for this factory

public setValidator(\Ramsey\Uuid\Validator\ValidatorInterface $validator): void

Parameters:

Parameter Type Description
$validator \Ramsey\Uuid\Validator\ValidatorInterface A validator to use for validating
whether a string is a valid UUID

fromBytes

Creates a UUID from a byte string

public fromBytes(string $bytes): \Ramsey\Uuid\UuidInterface

Parameters:

Parameter Type Description
$bytes string A binary string

Return Value:

A UuidInterface instance created from a binary string representation


fromString

Creates a UUID from the string standard representation

public fromString(string $uuid): \Ramsey\Uuid\UuidInterface

Parameters:

Parameter Type Description
$uuid string A hexadecimal string

Return Value:

A UuidInterface instance created from a hexadecimal string representation


fromInteger

Creates a UUID from a 128-bit integer string

public fromInteger(string $integer): \Ramsey\Uuid\UuidInterface

Parameters:

Parameter Type Description
$integer string String representation of 128-bit integer

Return Value:

A UuidInterface instance created from the string representation of a 128-bit integer


fromDateTime

Creates a UUID from a DateTimeInterface instance

public fromDateTime(\DateTimeInterface $dateTime, ?\Ramsey\Uuid\Type\Hexadecimal $node = null, ?int $clockSeq = null): \Ramsey\Uuid\UuidInterface

Parameters:

Parameter Type Description
$dateTime \DateTimeInterface The date and time
$node ?\Ramsey\Uuid\Type\Hexadecimal A 48-bit number representing the hardware
address
$clockSeq ?int 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:

A UuidInterface instance that represents a version 1 UUID created from a DateTimeInterface instance


fromHexadecimal

public fromHexadecimal(\Ramsey\Uuid\Type\Hexadecimal $hex): \Ramsey\Uuid\UuidInterface

Parameters:

Parameter Type Description
$hex \Ramsey\Uuid\Type\Hexadecimal

uuid1

Returns a version 1 (Gregorian time) UUID from a host ID, sequence number, and the current time

public uuid1(mixed $node = null, ?int $clockSeq = null): \Ramsey\Uuid\UuidInterface

Parameters:

Parameter Type Description
$node mixed A 48-bit number representing the
hardware address; this number may be represented as an integer or a
hexadecimal string
$clockSeq ?int 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:

A UuidInterface instance that represents a version 1 UUID


uuid2

Returns a version 2 (DCE Security) UUID from a local domain, local identifier, host ID, clock sequence, and the current time

public uuid2(int $localDomain, ?\Ramsey\Uuid\Type\Integer $localIdentifier = null, ?\Ramsey\Uuid\Type\Hexadecimal $node = null, ?int $clockSeq = null): \Ramsey\Uuid\UuidInterface

Parameters:

Parameter Type Description
$localDomain int The local domain to use when generating bytes,
according to DCE Security
$localIdentifier ?\Ramsey\Uuid\Type\Integer The local identifier for the
given domain; this may be a UID or GID on POSIX systems, if the local
domain is person or group, or it may be a site-defined identifier
if the local domain is org
$node ?\Ramsey\Uuid\Type\Hexadecimal A 48-bit number representing the hardware
address
$clockSeq ?int 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:

A UuidInterface instance that represents a version 2 UUID


uuid3

Returns a version 3 (name-based) UUID based on the MD5 hash of a namespace ID and a name

public uuid3(mixed $ns, string $name): \Ramsey\Uuid\UuidInterface

Parameters:

Parameter Type Description
$ns mixed The namespace (must be a valid UUID)
$name string The name to use for creating a UUID

Return Value:

A UuidInterface instance that represents a version 3 UUID


uuid4

Returns a version 4 (random) UUID

public uuid4(): \Ramsey\Uuid\UuidInterface

Return Value:

A UuidInterface instance that represents a version 4 UUID


uuid5

Returns a version 5 (name-based) UUID based on the SHA-1 hash of a namespace ID and a name

public uuid5(mixed $ns, string $name): \Ramsey\Uuid\UuidInterface

Parameters:

Parameter Type Description
$ns mixed The namespace (must be a valid UUID)
$name string The name to use for creating a UUID

Return Value:

A UuidInterface instance that represents a version 5 UUID


uuid6

Returns a version 6 (reordered time) UUID from a host ID, sequence number, and the current time

public uuid6(?\Ramsey\Uuid\Type\Hexadecimal $node = null, ?int $clockSeq = null): \Ramsey\Uuid\UuidInterface

Parameters:

Parameter Type Description
$node ?\Ramsey\Uuid\Type\Hexadecimal A 48-bit number representing the hardware
address
$clockSeq ?int 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:

A UuidInterface instance that represents a version 6 UUID


uuid7

Returns a version 7 (Unix Epoch time) UUID

public uuid7(\DateTimeInterface|null $dateTime = null): \Ramsey\Uuid\UuidInterface

Parameters:

Parameter Type Description
$dateTime \DateTimeInterface|null An optional date/time from which
to create the version 7 UUID. If not provided, the UUID is generated
using the current date/time.

Return Value:

A UuidInterface instance that represents a version 7 UUID


uuid8

Returns a version 8 (Custom) UUID

public uuid8(string $bytes): \Ramsey\Uuid\UuidInterface

The bytes provided may contain any value according to your application's needs. Be aware, however, that other applications may not understand the semantics of the value.

Parameters:

Parameter Type Description
$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.

Return Value:

A UuidInterface instance that represents a version 8 UUID


uuid

Returns a Uuid created from the provided byte string

public uuid(string $bytes): \Ramsey\Uuid\UuidInterface

Uses the configured builder and codec and the provided byte string to construct a Uuid object.

Parameters:

Parameter Type Description
$bytes string The byte string from which to construct a UUID

Return Value:

An instance of UuidInterface, created from the provided bytes


uuidFromNsAndName

Returns a version 3 or 5 namespaced Uuid

private uuidFromNsAndName(string|\Ramsey\Uuid\UuidInterface $ns, string $name, int $version, string $hashAlgorithm): \Ramsey\Uuid\UuidInterface

Parameters:

Parameter Type Description
$ns string|\Ramsey\Uuid\UuidInterface The namespace (must be a valid UUID)
$name string The name to hash together with the namespace
$version int The version of UUID to create (3 or 5)
$hashAlgorithm string The hashing algorithm to use when hashing
together the namespace and name

Return Value:

An instance of UuidInterface, created by hashing together the provided namespace and name


uuidFromBytesAndVersion

Returns an RFC 4122 variant Uuid, created from the provided bytes and version

private uuidFromBytesAndVersion(string $bytes, int $version): \Ramsey\Uuid\UuidInterface

Parameters:

Parameter Type Description
$bytes string The byte string to convert to a UUID
$version int The RFC 4122 version to apply to the UUID

Return Value:

An instance of UuidInterface, created from the byte string and version



Automatically generated on 2025-03-18