aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/ramsey/uuid/src/Rfc4122/UuidV2.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/ramsey/uuid/src/Rfc4122/UuidV2.php')
-rw-r--r--vendor/ramsey/uuid/src/Rfc4122/UuidV2.php56
1 files changed, 14 insertions, 42 deletions
diff --git a/vendor/ramsey/uuid/src/Rfc4122/UuidV2.php b/vendor/ramsey/uuid/src/Rfc4122/UuidV2.php
index 74906f050..c8ccbe422 100644
--- a/vendor/ramsey/uuid/src/Rfc4122/UuidV2.php
+++ b/vendor/ramsey/uuid/src/Rfc4122/UuidV2.php
@@ -14,28 +14,33 @@ declare(strict_types=1);
namespace Ramsey\Uuid\Rfc4122;
-use DateTimeImmutable;
-use DateTimeInterface;
use Ramsey\Uuid\Codec\CodecInterface;
use Ramsey\Uuid\Converter\NumberConverterInterface;
use Ramsey\Uuid\Converter\TimeConverterInterface;
-use Ramsey\Uuid\Exception\DateTimeException;
use Ramsey\Uuid\Exception\InvalidArgumentException;
use Ramsey\Uuid\Rfc4122\FieldsInterface as Rfc4122FieldsInterface;
use Ramsey\Uuid\Type\Integer as IntegerObject;
use Ramsey\Uuid\Uuid;
-use Throwable;
use function hexdec;
-use function str_pad;
-
-use const STR_PAD_LEFT;
/**
* DCE Security version, or version 2, UUIDs include local domain identifier,
* local ID for the specified domain, and node values that are combined into a
* 128-bit unsigned integer
*
+ * It is important to note that a version 2 UUID suffers from some loss of
+ * fidelity of the timestamp, due to replacing the time_low field with the
+ * local identifier. When constructing the timestamp value for date
+ * purposes, we replace the local identifier bits with zeros. As a result,
+ * the timestamp can be off by a range of 0 to 429.4967295 seconds (or 7
+ * minutes, 9 seconds, and 496730 microseconds).
+ *
+ * Astute observers might note this value directly corresponds to 2^32 - 1,
+ * or 0xffffffff. The local identifier is 32-bits, and we have set each of
+ * these bits to 0, so the maximum range of timestamp drift is 0x00000000
+ * to 0xffffffff (counted in 100-nanosecond intervals).
+ *
* @link https://publications.opengroup.org/c311 DCE 1.1: Authentication and Security Services
* @link https://publications.opengroup.org/c706 DCE 1.1: Remote Procedure Call
* @link https://pubs.opengroup.org/onlinepubs/9696989899/chap5.htm#tagcjh_08_02_01_01 DCE 1.1: Auth & Sec, ยง5.2.1.1
@@ -47,6 +52,8 @@ use const STR_PAD_LEFT;
*/
final class UuidV2 extends Uuid implements UuidInterface
{
+ use TimeTrait;
+
/**
* Creates a version 2 (DCE Security) UUID
*
@@ -75,41 +82,6 @@ final class UuidV2 extends Uuid implements UuidInterface
}
/**
- * Returns a DateTimeInterface object representing the timestamp associated
- * with the UUID
- *
- * It is important to note that a version 2 UUID suffers from some loss of
- * fidelity of the timestamp, due to replacing the time_low field with the
- * local identifier. When constructing the timestamp value for date
- * purposes, we replace the local identifier bits with zeros. As a result,
- * the timestamp can be off by a range of 0 to 429.4967295 seconds (or 7
- * minutes, 9 seconds, and 496730 microseconds).
- *
- * Astute observers might note this value directly corresponds to 2^32 - 1,
- * or 0xffffffff. The local identifier is 32-bits, and we have set each of
- * these bits to 0, so the maximum range of timestamp drift is 0x00000000
- * to 0xffffffff (counted in 100-nanosecond intervals).
- *
- * @return DateTimeImmutable A PHP DateTimeImmutable instance representing
- * the timestamp of a version 2 UUID
- */
- public function getDateTime(): DateTimeInterface
- {
- $time = $this->timeConverter->convertTime($this->fields->getTimestamp());
-
- try {
- return new DateTimeImmutable(
- '@'
- . $time->getSeconds()->toString()
- . '.'
- . str_pad($time->getMicroseconds()->toString(), 6, '0', STR_PAD_LEFT)
- );
- } catch (Throwable $e) {
- throw new DateTimeException($e->getMessage(), (int) $e->getCode(), $e);
- }
- }
-
- /**
* Returns the local domain used to create this version 2 UUID
*/
public function getLocalDomain(): int