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
bool
True if $obj is equal to this UUIDfromBytes(string $bytes) : \Rhumsaa\Uuid\Uuid
string
\InvalidArgumentException |
If the $bytes string does not contain 16 characters |
---|
fromString(string $name) : \Rhumsaa\Uuid\Uuid
string
A string that specifies a UUID
\InvalidArgumentException |
If the $name isn't a valid UUID |
---|
getBytes() : string
string
getClockSeqHiAndReserved() : int
int
Unsigned 8-bit integer value of clock_seq_hi_and_reservedgetClockSeqHiAndReservedHex() : string
string
Hexadecimal value of clock_seq_hi_and_reservedgetClockSeqLow() : int
int
Unsigned 8-bit integer value of clock_seq_lowgetClockSeqLowHex() : string
string
Hexadecimal 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 |
---|
int
Unsigned 14-bit integer value of clock sequencegetClockSequenceHex() : string
string
Hexadecimal 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 |
\DateTime
A 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 |
---|
array
The UUID fields represented as integer valuesgetFieldsHex() : array
array
The UUID fields represented as hexadecimal valuesgetLeastSignificantBits() : \Moontoast\Math\BigNumber
\Rhumsaa\Uuid\Exception\UnsatisfiedDependencyException |
if Moontoast\Math\BigNumber is not present |
---|
\Moontoast\Math\BigNumber
BigNumber representation of the unsigned 64-bit integer valuegetLeastSignificantBitsHex() : string
string
Hexadecimal value of least significant bitsgetMostSignificantBits() : \Moontoast\Math\BigNumber
\Rhumsaa\Uuid\Exception\UnsatisfiedDependencyException |
if Moontoast\Math\BigNumber is not present |
---|
\Moontoast\Math\BigNumber
BigNumber representation of the unsigned 64-bit integer valuegetMostSignificantBitsHex() : string
string
Hexadecimal 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 |
---|
int
Unsigned 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 |
---|
string
Hexadecimal value of nodegetTimeHiAndVersion() : int
int
Unsigned 16-bit integer value of time_hi_and_versiongetTimeHiAndVersionHex() : string
string
Hexadecimal value of time_hi_and_versiongetTimeLow() : int
\Rhumsaa\Uuid\Exception\UnsatisfiedDependencyException |
if called on a 32-bit system |
---|
int
Unsigned 32-bit integer value of time_lowgetTimeLowHex() : string
string
Hexadecimal value of time_lowgetTimeMid() : int
int
Unsigned 16-bit integer value of time_midgetTimeMidHex() : string
string
Hexadecimal 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 |
int
Unsigned 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 |
---|
string
Hexadecimal 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 |
---|
int
getVersion() : 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 |
---|
int
isValid(string $uuid) : boolean
string
The uuid to test
boolean
toString() : string
string
uuid1(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.
int
string
A 48-bit number representing the hardware address. This number may be represented as an integer or a hexadecimal string.
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.
\InvalidArgumentException |
if the $node is invalid |
---|
uuid3(\Rhumsaa\Uuid\Uuid | string $ns, string $name) : \Rhumsaa\Uuid\Uuid
string
The name to create a UUID for
uuid5(\Rhumsaa\Uuid\Uuid | string $ns, string $name) : \Rhumsaa\Uuid\Uuid
string
The 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.
int
Seconds since the Unix Epoch
int
Microseconds
\Rhumsaa\Uuid\Exception\UnsatisfiedDependencyException |
if called on a 32-bit system and Moontoast\Math\BigNumber is not present |
---|
array
getNodeFromSystem() : 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. |
---|
string
hasBigNumber() : bool
bool
is64BitSystem() : bool
bool
uuidFromHashedName(string $hash, int $version) : \Rhumsaa\Uuid\Uuid
string
The hash to use when creating the UUID
int
The 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