diff --git a/README.md b/README.md index 63aca60..ee152f0 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,6 @@ build a 64-bit version. ```php $compareTo($uuid2)) { + case -1: + echo "$uuid1 is less than $uuid2"; + break; + case 1: + echo "$uuid1 is greater than $uuid2"; + break; + case 0: + default: + echo "$uuid1 is equal to $uuid2"; + } + +bool **equals($obj)** +Compares this UUID to the specified object and returns `true` if they are equal. + +string **getBytes()** +Returns the UUID as a 16-byte string. + +int **getClockSeqHiAndReserved()** +Returns the high field of the clock sequence multiplexed with the variant +(bits 65-72 of the UUID). + +int **getClockSeqLow()** +Returns the low field of the clock sequence (bits 73-80 of the UUID). + +int **getClockSequence()** +Returns the full clock sequence, including the high and low fields. + +\DateTime **getDateTime()** +For version 1 UUIDs, this returns a PHP DateTime object representing the date +and time used to create the UUID. + +array **getFields()** +Returns an array of the fields of the UUID, with keys named according to the +RFC 4122 names for the fields. + +| Field | Meaning | +| -------------------------- | ------------------------------- | +| time_low | the first 32 bits of the UUID | +| time_mid | the next 16 bits of the UUID | +| time_hi_and_version | the next 16 bits of the UUID | +| clock_seq_hi_and_reserved | the next 8 bits of the UUID | +| clock_seq_low | the next 8 bits of the UUID | +| node | the last 48 bits of the UUID | + +int **getLeastSignificantBits()** +Returns the least significant 64 bits of this UUID's 128 bit value. + +int **getMostSignificantBits()** +Returns the most significant 64 bits of this UUID's 128 bit value. + +int **getNode()** +Returns the node value associated with this UUID. + +int **getTimeHiAndVersion()** +Returns the high field of the timestamp multiplexed with the version number +(bits 49-64 of the UUID). + +int **getTimeLow()** +Returns the low field of the timestamp (the first 32 bits of the UUID). + +int **getTimeMid()** +Returns the middle field of the timestamp (bits 33-48 of the UUID). + +int **getTimestamp()** +For version 1 UUIDs, this returns the 60 bit timestamp value used to create +this UUID. The timestamp is measured in 100-nanosecond units since midnight, +October 15, 1582, UTC. It is not a Unix timestamp. + +string **getUrn()** +Returns the string representation of the UUID as a URN. + +int **getVariant()** +Returns the variant number associated with this 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 + +int **getVersion()** +The version number associated with this UUID. The version number describes how +this UUID was generated. + +The version number 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 + +string **toString()** +Converts this UUID into a string representation. This class also implements +__toString(), which will convert this object to a string when it is used in +any string context. + ## Installation diff --git a/tests/Rhumsaa/Uuid/UuidTest.php b/tests/Rhumsaa/Uuid/UuidTest.php index 3485573..0b22a3a 100644 --- a/tests/Rhumsaa/Uuid/UuidTest.php +++ b/tests/Rhumsaa/Uuid/UuidTest.php @@ -507,10 +507,10 @@ class UuidTest extends \PHPUnit_Framework_TestCase // The next three UUIDs are used for comparing msb and lsb in // the compareTo() method - // msb are greater than $uuid4, lsb are greater than $uuid5 + // msb are less than $uuid4, lsb are greater than $uuid5 $uuid3 = Uuid::fromString('44cca71e-d13d-11e1-a959-c8bcc8a476f4'); - // msb are less than in $uuid3, lsb are equal to those in $uuid3 + // msb are greater than $uuid3, lsb are equal to those in $uuid3 $uuid4 = Uuid::fromString('44cca71e-d13d-11e2-a959-c8bcc8a476f4'); // msb are equal to those in $uuid3, lsb are less than in $uuid3