UuidFactory
- Full name:
\Ramsey\Uuid\UuidFactory
- This class implements:
\Ramsey\Uuid\UuidFactoryInterface
Properties
codec
dceSecurityGenerator
nameGenerator
nodeProvider
numberConverter
randomGenerator
timeConverter
timeGenerator
unixTimeGenerator
uuidBuilder
validator
isDefaultFeatureSet
Methods
__construct
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
setCodec
Sets the codec to use for this factory
Parameters:
Parameter | Type | Description |
---|---|---|
$codec |
\Ramsey\Uuid\Codec\CodecInterface | A UUID encoder-decoder |
getNameGenerator
Returns the name generator used by this factory
setNameGenerator
Sets the name generator to use for this factory
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
getRandomGenerator
Returns the random generator used by this factory
getTimeGenerator
Returns the time generator used by this factory
setTimeGenerator
Sets the time generator to use for this factory
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
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
setRandomGenerator
Sets the random generator to use for this factory
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
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
setUuidBuilder
Sets the UUID builder to use for this factory
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
setValidator
Sets the validator to use for this factory
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
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
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
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
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
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
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
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
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
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
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
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
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