Represents a universally unique identifier (UUID), according to RFC 4122
This class provides immutable UUID objects (the Uuid class) and the static
methods uuid1(), uuid3(), uuid4(), and uuid5() for generating version
1, 3, 4, and 5 UUIDs as specified in RFC 4122.
If all you want is a unique ID, you should probably call uuid1() or uuid4().
Note that uuid1() may compromise privacy since it creates a UUID containing
the computer’s network address. uuid4() creates a random UUID.
__toString() : string
compareTo(\Rhumsaa\Uuid\Uuid $uuid) : 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.
int-1, 0 or 1 as this UUID is less than, equal to, or greater than $uuidequals(object $obj) : 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.
object
boolTrue if $obj is equal to this UUIDfromString(string $name) : \Rhumsaa\Uuid\Uuid
stringA string that specifies a UUID
\InvalidArgumentException |
If the $name isn't a valid UUID |
|---|
getBytes() : string
stringgetClockSeqHiAndReserved() : int
intUnsigned 8-bit integer value of clock_seq_hi_and_reservedgetClockSeqHiAndReservedHex() : string
stringHexadecimal value of clock_seq_hi_and_reservedgetClockSeqLow() : int
intUnsigned 8-bit integer value of clock_seq_lowgetClockSeqLowHex() : string
stringHexadecimal value of clock_seq_lowgetClockSequence() : int
For UUID version 1, the clock sequence is used to help avoid duplicates that could arise when the clock is set backwards in time or if the node ID changes.
For UUID version 3 or 5, the clock sequence is a 14-bit value constructed from a name as described in RFC 4122, Section 4.3.
For UUID version 4, clock sequence is a randomly or pseudo-randomly generated 14-bit value as described in RFC 4122, Section 4.4.
| link | http://tools.ietf.org/html/rfc4122#section-4.1.5 |
|---|
intUnsigned 14-bit integer value of clock sequencegetClockSequenceHex() : string
stringHexadecimal value of clock sequencegetDateTime() : \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.
\Rhumsaa\Uuid\Exception\UnsupportedOperationException |
If this UUID is not a version 1 UUID |
|---|---|
\Rhumsaa\Uuid\Exception\UnsatisfiedDependencyException |
if called on a 32-bit system and Moontoast\Math\BigNumber is not present |
\DateTimeA PHP DateTime representation of the dategetFields() : array
| link | http://tools.ietf.org/html/rfc4122#section-4.1.2 |
|---|
\Rhumsaa\Uuid\Exception\UnsatisfiedDependencyException |
if called on a 32-bit system |
|---|
arrayThe UUID fields represented as integer valuesgetFieldsHex() : array
arrayThe UUID fields represented as hexadecimal valuesgetLeastSignificantBits() : \Moontoast\Math\BigNumber
\Rhumsaa\Uuid\Exception\UnsatisfiedDependencyException |
if Moontoast\Math\BigNumber is not present |
|---|
\Moontoast\Math\BigNumberBigNumber representation of the unsigned 64-bit integer valuegetLeastSignificantBitsHex() : string
stringHexadecimal value of least significant bitsgetMostSignificantBits() : \Moontoast\Math\BigNumber
\Rhumsaa\Uuid\Exception\UnsatisfiedDependencyException |
if Moontoast\Math\BigNumber is not present |
|---|
\Moontoast\Math\BigNumberBigNumber representation of the unsigned 64-bit integer valuegetMostSignificantBitsHex() : string
stringHexadecimal value of most significant bitsgetNode() : int
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.
| link | http://tools.ietf.org/html/rfc4122#section-4.1.6 |
|---|
\Rhumsaa\Uuid\Exception\UnsatisfiedDependencyException |
if called on a 32-bit system |
|---|
intUnsigned 48-bit integer value of nodegetNodeHex() : 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.
| link | http://tools.ietf.org/html/rfc4122#section-4.1.6 |
|---|
stringHexadecimal value of nodegetTimeHiAndVersion() : int
intUnsigned 16-bit integer value of time_hi_and_versiongetTimeHiAndVersionHex() : string
stringHexadecimal value of time_hi_and_versiongetTimeLow() : int
\Rhumsaa\Uuid\Exception\UnsatisfiedDependencyException |
if called on a 32-bit system |
|---|
intUnsigned 32-bit integer value of time_lowgetTimeLowHex() : string
stringHexadecimal value of time_lowgetTimeMid() : int
intUnsigned 16-bit integer value of time_midgetTimeMidHex() : string
stringHexadecimal value of time_midgetTimestamp() : int
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.
| link | http://tools.ietf.org/html/rfc4122#section-4.1.4 |
|---|
\Rhumsaa\Uuid\Exception\UnsupportedOperationException |
If this UUID is not a version 1 UUID |
|---|---|
\Rhumsaa\Uuid\Exception\UnsatisfiedDependencyException |
if called on a 32-bit system |
intUnsigned 60-bit integer value of the timestampgetTimestampHex() : 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.
| link | http://tools.ietf.org/html/rfc4122#section-4.1.4 |
|---|
\Rhumsaa\Uuid\Exception\UnsupportedOperationException |
If this UUID is not a version 1 UUID |
|---|
stringHexadecimal value of the timestampgetUrn() : string
getVariant() : int
The variant number describes the layout of the UUID. The variant number has the following meaning:
| link | http://tools.ietf.org/html/rfc4122#section-4.1.1 |
|---|
intgetVersion() : int
The version number describes how this UUID was generated.
The version number has the following meaning:
| link | http://tools.ietf.org/html/rfc4122#section-4.1.3 |
|---|
inttoString() : string
stringuuid1(int | string $node, int $clockSeq) : \Rhumsaa\Uuid\Uuid
If $node is not given, getMacAddress() is used to obtain the hardware address. If $clockSeq is given, it is used as the sequence number; otherwise a random 14-bit sequence number is chosen.
intstringA 48-bit number representing the hardware address. This number may be represented as an integer or a hexadecimal string.
intA 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.
\InvalidArgumentException |
if the $node is invalid |
|---|
uuid3(\Rhumsaa\Uuid\Uuid | string $ns, string $name) : \Rhumsaa\Uuid\Uuid
stringThe name to create a UUID for
uuid5(\Rhumsaa\Uuid\Uuid | string $ns, string $name) : \Rhumsaa\Uuid\Uuid
stringThe name to create a UUID for
__construct(array $fields)
Protected to prevent direct instantiation. Use static methods to create UUIDs.
array
calculateUuidTime(int $sec, int $usec) : array
UUID time is a 60-bit time value as a count of 100-nanosecond intervals since 00:00:00.00, 15 October 1582.
intSeconds since the Unix Epoch
intMicroseconds
\Rhumsaa\Uuid\Exception\UnsatisfiedDependencyException |
if called on a 32-bit system and Moontoast\Math\BigNumber is not present |
|---|
arraygetNodeFromSystem() : string
If all attempts to obtain the hardware address fail, we choose a random 48-bit number with its eighth bit set to 1 as recommended in RFC 4122. "Hardware address" means the MAC address of a network interface, and on a machine with multiple network interfaces the MAC address of any one of them may be returned.
| todo | Needs evaluation and possibly modification to ensure this works well across multiple platforms. |
|---|
stringhasBigNumber() : bool
boolis64BitSystem() : bool
booluuidFromHashedName(string $hash, int $version) : \Rhumsaa\Uuid\Uuid
stringThe hash to use when creating the UUID
intThe UUID version to be generated
$force32Bit : bool
$forceNoBigNumber : bool
$ignoreSystemNode : bool
$timeOfDayTest : array
$fields : array
This is initialized to the nil value.
| see | \Rhumsaa\Uuid\Uuid::getFields |
|---|
NAMESPACE_DNS
NAMESPACE_OID
NAMESPACE_URL
NAMESPACE_X500
NIL
RESERVED_FUTURE
RESERVED_MICROSOFT
RFC_4122