Documentation

UuidInterface extends JsonSerializable, Serializable

UuidInterface defines common functionality for all universally unique identifiers (UUIDs)

Table of Contents

compareTo()  : int
Compares this UUID to the specified UUID.
equals()  : bool
Compares this object to the specified object.
getBytes()  : string
Returns the UUID as a 16-byte string (containing the six integer fields in big-endian byte order).
getClockSeqHiAndReservedHex()  : string
Returns the high field of the clock sequence multiplexed with the variant (bits 65-72 of the UUID).
getClockSeqLowHex()  : string
Returns the low field of the clock sequence (bits 73-80 of the UUID).
getClockSequenceHex()  : string
Returns the clock sequence value associated with this UUID.
getDateTime()  : DateTime
Returns a PHP `DateTime` object representing the timestamp associated with this UUID.
getFieldsHex()  : array<string|int, mixed>
Returns an array of the fields of this UUID, with keys named according to the RFC 4122 names for the fields.
getHex()  : string
Returns the hexadecimal value of the UUID.
getInteger()  : mixed
Returns the integer value of the UUID, converted to an appropriate number representation.
getLeastSignificantBitsHex()  : string
Returns the least significant 64 bits of this UUID's 128 bit value.
getMostSignificantBitsHex()  : string
Returns the most significant 64 bits of this UUID's 128 bit value.
getNodeHex()  : string
Returns the node value associated with this UUID
getNumberConverter()  : NumberConverterInterface
Returns the number converter to use for converting hex values to/from integers.
getTimeHiAndVersionHex()  : string
Returns the high field of the timestamp multiplexed with the version number (bits 49-64 of the UUID).
getTimeLowHex()  : string
Returns the low field of the timestamp (the first 32 bits of the UUID).
getTimeMidHex()  : string
Returns the middle field of the timestamp (bits 33-48 of the UUID).
getTimestampHex()  : string
Returns the timestamp value associated with this UUID.
getUrn()  : string
Returns the string representation of the UUID as a URN.
getVariant()  : int
Returns the variant number associated with this UUID.
getVersion()  : int|null
Returns the version number associated with this UUID.
jsonSerialize()  : mixed
Specify data which should be serialized to JSON.
toString()  : string
Converts this UUID into a string representation.

Methods

compareTo()

Compares this UUID to the specified UUID.

public compareTo(UuidInterface $other) : int

The first of two UUIDs is greater than the second if the most significant field in which the UUIDs differ is greater for the first UUID.

  • Q. What's the value of being able to sort UUIDs?
  • A. Use them as keys in a B-Tree or similar mapping.
Parameters
$other : UuidInterface

UUID to which this UUID is compared

Return values
int

-1, 0 or 1 as this UUID is less than, equal to, or greater than $uuid

equals()

Compares this object to the specified object.

public equals(object $other) : bool

The result is true if and only if the argument is not null, is a UUID object, has the same variant, and contains the same value, bit for bit, as this UUID.

Parameters
$other : object
Return values
bool

True if $other is equal to this UUID

getBytes()

Returns the UUID as a 16-byte string (containing the six integer fields in big-endian byte order).

public getBytes() : string
Return values
string

getClockSeqHiAndReservedHex()

Returns the high field of the clock sequence multiplexed with the variant (bits 65-72 of the UUID).

public getClockSeqHiAndReservedHex() : string
Return values
string

Hexadecimal value of clock_seq_hi_and_reserved

getClockSeqLowHex()

Returns the low field of the clock sequence (bits 73-80 of the UUID).

public getClockSeqLowHex() : string
Return values
string

Hexadecimal value of clock_seq_low

getClockSequenceHex()

Returns the clock sequence value associated with this UUID.

public getClockSequenceHex() : string
Return values
string

Hexadecimal value of clock sequence

getDateTime()

Returns a PHP `DateTime` object representing the timestamp associated with this UUID.

public getDateTime() : DateTime

The timestamp value is only meaningful in a time-based UUID, which has version type 1. If this UUID is not a time-based UUID then this method throws UnsupportedOperationException.

Tags
throws
UnsupportedOperationException

If this UUID is not a version 1 UUID

throws
UnsatisfiedDependencyException

if called in a 32-bit system and Moontoast\Math\BigNumber is not present

Return values
DateTime

A PHP DateTime representation of the date

getFieldsHex()

Returns an array of the fields of this UUID, with keys named according to the RFC 4122 names for the fields.

public getFieldsHex() : array<string|int, mixed>
  • time_low: The low field of the timestamp, an unsigned 32-bit integer
  • time_mid: The middle field of the timestamp, an unsigned 16-bit integer
  • time_hi_and_version: The high field of the timestamp multiplexed with the version number, an unsigned 16-bit integer
  • clock_seq_hi_and_reserved: The high field of the clock sequence multiplexed with the variant, an unsigned 8-bit integer
  • clock_seq_low: The low field of the clock sequence, an unsigned 8-bit integer
  • node: The spatially unique node identifier, an unsigned 48-bit integer
Return values
array<string|int, mixed>

The UUID fields represented as hexadecimal values

getHex()

Returns the hexadecimal value of the UUID.

public getHex() : string
Return values
string

getInteger()

Returns the integer value of the UUID, converted to an appropriate number representation.

public getInteger() : mixed
Tags
throws
UnsatisfiedDependencyException

if Moontoast\Math\BigNumber is not present

Return values
mixed

Converted representation of the unsigned 128-bit integer value

getLeastSignificantBitsHex()

Returns the least significant 64 bits of this UUID's 128 bit value.

public getLeastSignificantBitsHex() : string
Return values
string

Hexadecimal value of least significant bits

getMostSignificantBitsHex()

Returns the most significant 64 bits of this UUID's 128 bit value.

public getMostSignificantBitsHex() : string
Return values
string

Hexadecimal value of most significant bits

getNodeHex()

Returns the node value associated with this UUID

public getNodeHex() : string

For UUID version 1, the node field consists of an IEEE 802 MAC address, usually the host address. For systems with multiple IEEE 802 addresses, any available one can be used. The lowest addressed octet (octet number 10) contains the global/local bit and the unicast/multicast bit, and is the first octet of the address transmitted on an 802.3 LAN.

For systems with no IEEE address, a randomly or pseudo-randomly generated value may be used; see RFC 4122, Section 4.5. The multicast bit must be set in such addresses, in order that they will never conflict with addresses obtained from network cards.

For UUID version 3 or 5, the node field is a 48-bit value constructed from a name as described in RFC 4122, Section 4.3.

For UUID version 4, the node field is a randomly or pseudo-randomly generated 48-bit value as described in RFC 4122, Section 4.4.

Tags
link
http://tools.ietf.org/html/rfc4122#section-4.1.6
Return values
string

Hexadecimal value of node

getTimeHiAndVersionHex()

Returns the high field of the timestamp multiplexed with the version number (bits 49-64 of the UUID).

public getTimeHiAndVersionHex() : string
Return values
string

Hexadecimal value of time_hi_and_version

getTimeLowHex()

Returns the low field of the timestamp (the first 32 bits of the UUID).

public getTimeLowHex() : string
Return values
string

Hexadecimal value of time_low

getTimeMidHex()

Returns the middle field of the timestamp (bits 33-48 of the UUID).

public getTimeMidHex() : string
Return values
string

Hexadecimal value of time_mid

getTimestampHex()

Returns the timestamp value associated with this UUID.

public getTimestampHex() : string

The 60 bit timestamp value is constructed from the time_low, time_mid, and time_hi fields of this UUID. The resulting timestamp is measured in 100-nanosecond units since midnight, October 15, 1582 UTC.

The timestamp value is only meaningful in a time-based UUID, which has version type 1. If this UUID is not a time-based UUID then this method throws UnsupportedOperationException.

Tags
throws
UnsupportedOperationException

If this UUID is not a version 1 UUID

link
http://tools.ietf.org/html/rfc4122#section-4.1.4
Return values
string

Hexadecimal value of the timestamp

getVariant()

Returns the variant number associated with this UUID.

public getVariant() : int

The variant number describes the layout of the UUID. The variant number has the following meaning:

  • 0 - Reserved for NCS backward compatibility
  • 2 - The RFC 4122 variant (used by this class)
  • 6 - Reserved, Microsoft Corporation backward compatibility
  • 7 - Reserved for future definition
Tags
link
http://tools.ietf.org/html/rfc4122#section-4.1.1
Return values
int

getVersion()

Returns the version number associated with this UUID.

public getVersion() : int|null

The version number describes how this UUID was generated and has the following meaning:

  • 1 - Time-based UUID
  • 2 - DCE security UUID
  • 3 - Name-based UUID hashed with MD5
  • 4 - Randomly generated UUID
  • 5 - Name-based UUID hashed with SHA-1

Returns null if this UUID is not an RFC 4122 variant, since version is only meaningful for this variant.

Tags
link
http://tools.ietf.org/html/rfc4122#section-4.1.3
Return values
int|null

toString()

Converts this UUID into a string representation.

public toString() : string
Return values
string

Search results