Base Class and Interfaces ######################### .. highlight:: php Base class ========== ``Arokettu\Uuid\AbstractUuid`` class and ``Arokettu\Uuid\Uuid`` interface. Direct creation --------------- The base constructor is inherited by most of the descendants. It accepts a string of lowercase hexadecimal digits (0-9, a-f):: toDecimal(); // 2.25.143098242483405524118141958906375844040 Comparison ---------- Methods to compare two UUID objects. * ``compare(): int``. Returns same thing as strcmp_. * ``equalTo(): bool``. In strict mode (by default) returns true if bytes and types of the two objects are equal. In non-strict mode compares only byte values. :: compare($ulid)); // 0 var_dump($uuid->equalTo($ulid)); // false var_dump($uuid->equalTo($ulid, strict: false)); // true Variant10xxUuid =============== .. versionadded:: 1.1 .. versionchanged:: 1.2 renamed from Rfc4122Variant1Uuid to Rfc4122Variant10xxUuid .. versionchanged:: 3.0 renamed from Rfc4122Variant10xxUuid to Variant10xxUuid `RFC 9562`_ Variant 10xx UUID versions (all except for Nil and Max) extend this interface. This interface is most useful to check that it is a standard based UUID as opposed to Nil, Max, ULID or unrecognized generic. :: getVersion()); // 4 $ulid = UlidFactory::ulid(); var_dump($ulid instanceof Variant10xxUuid); // false Rfc4122Uuid =========== .. versionchanged:: 1.1 Now includes Nil and Max .. versionchanged:: 3.0 No longer contains Max, UUIDv2, UUIDv6, UUIDv7, UUIDv8 All UUIDs mentioned in `RFC 4122`_, i.e. Nil, and Variant10xxUuid versions 1-5 excluding 2. Rfc9562Uuid =========== .. versionadded:: 3.0 All UUIDs mentioned in `RFC 9562`_, i.e. Nil, Max, Variant10xxUuid versions 1-8 excluding 2. TimeBasedUuid ============= UUIDv1, UUIDv2, UUIDv6, UUIDv7, and ULID extend this interface because they encode timestamp with various precisions:: getDateTime()->format('c')); // current time .. _RFC 4122: https://datatracker.ietf.org/doc/html/rfc4122 .. _RFC 9562: https://datatracker.ietf.org/doc/html/rfc9562 .. _strcmp: https://www.php.net/manual/en/function.strcmp.php NodeBasedUuid ============= .. versionadded:: 4.0 UUIDv1, UUIDv2, and UUIDv6 extend this interface because they are based on a Node and a Clock Sequence:: getNode()); // Node value (MAC address or MAC-like pseudo-value) var_dump($uuid->getClockSequence()); // Clock Sequence value