Fields
RFC 4122 variant UUIDs are comprised of a set of named fields
Internally, this class represents the fields together as a 16-byte binary string.
- Full name:
\Ramsey\Uuid\Rfc4122\Fields
- This class is marked as final and can't be subclassed
- This class implements:
\Ramsey\Uuid\Rfc4122\FieldsInterface
- This class is a Final class
Properties
bytes
Methods
__construct
Parameters:
Parameter | Type | Description |
---|---|---|
$bytes |
string | A 16-byte binary string representation of a UUID |
Throws:
if the byte string is not exactly 16 bytes
if the byte string does not represent an RFC 4122 UUID
if the byte string does not contain a valid version
getBytes
Returns the bytes that comprise the fields
getClockSeq
Returns the full 16-bit clock sequence, with the variant bits (two most significant bits) masked out
getClockSeqHiAndReserved
Returns the high field of the clock sequence multiplexed with the variant
getClockSeqLow
Returns the low field of the clock sequence
getNode
Returns the node field
getTimeHiAndVersion
Returns the high field of the timestamp multiplexed with the version
getTimeLow
Returns the low field of the timestamp
getTimeMid
Returns the middle field of the timestamp
getTimestamp
Returns the full 60-bit timestamp, without the version
For version 2 UUIDs, the time_low field is the local identifier and should not be returned as part of the time. For this reason, we set the bottom 32 bits of the timestamp to 0's. As a result, there is some loss of fidelity of the timestamp, for version 2 UUIDs. The timestamp can be off by a range of 0 to 429.4967295 seconds (or 7 minutes, 9 seconds, and 496730 microseconds).
For version 6 UUIDs, the timestamp order is reversed from the typical RFC 4122 order (the time bits are in the correct bit order, so that it is monotonically increasing). In returning the timestamp value, we put the bits in the order: time_low + time_mid + time_hi.
getVersion
Returns the version
The version number describes how the UUID was generated and has the following meaning:
- Gregorian time UUID
- DCE security UUID
- Name-based UUID hashed with MD5
- Randomly generated UUID
- Name-based UUID hashed with SHA-1
- Reordered time UUID
- Unix Epoch time UUID
This returns null
if the UUID is not an RFC 4122 variant, since version
is only meaningful for this variant.
isCorrectVariant
Inherited methods
getVersion
Returns the version
- This method is abstract.
isMax
Returns true if the byte string represents a max UUID
isNil
Returns true if the byte string represents a nil UUID
isCorrectVersion
Returns true if the version matches one of those defined by RFC 4122
Return Value:
True if the UUID version is valid, false otherwise
getBytes
Returns the bytes that comprise the fields
- This method is abstract.
getVariant
Returns the variant identifier, according to RFC 4122, for the given bytes
The following values may be returned:
0
-- Reserved, NCS backward compatibility.2
-- The variant specified in RFC 4122.6
-- Reserved, Microsoft Corporation backward compatibility.7
-- Reserved for future definition.
Return Value:
The variant identifier, according to RFC 4122
See Also:
- https://tools.ietf.org/html/rfc4122#section-4.1.1 - RFC 4122, ยง 4.1.1: Variant
__construct
- This method is abstract.
Parameters:
Parameter | Type | Description |
---|---|---|
$bytes |
string | The bytes that comprise the fields |
serialize
Returns a string representation of object
__serialize
unserialize
Constructs the object from a serialized string representation
Parameters:
Parameter | Type | Description |
---|---|---|
$data |
string | The serialized string representation of the object |
__unserialize
Parameters:
Parameter | Type | Description |
---|---|---|
$data |
array{bytes?: string} |
Automatically generated on 2025-03-18