diff options
Diffstat (limited to 'vendor/ramsey/uuid/src/Rfc4122/VariantTrait.php')
-rw-r--r-- | vendor/ramsey/uuid/src/Rfc4122/VariantTrait.php | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/vendor/ramsey/uuid/src/Rfc4122/VariantTrait.php b/vendor/ramsey/uuid/src/Rfc4122/VariantTrait.php index 1041de51e..4c981658f 100644 --- a/vendor/ramsey/uuid/src/Rfc4122/VariantTrait.php +++ b/vendor/ramsey/uuid/src/Rfc4122/VariantTrait.php @@ -19,8 +19,8 @@ use Ramsey\Uuid\Uuid; use function decbin; use function str_pad; -use function str_starts_with; use function strlen; +use function strpos; use function substr; use function unpack; @@ -58,13 +58,7 @@ trait VariantTrait throw new InvalidBytesException('Invalid number of bytes'); } - if ($this->isMax() || $this->isNil()) { - // RFC 4122 defines these special types of UUID, so we will consider - // them as belonging to the RFC 4122 variant. - return Uuid::RFC_4122; - } - - /** @var int[] $parts */ + /** @var array $parts */ $parts = unpack('n*', $this->getBytes()); // $parts[5] is a 16-bit, unsigned integer containing the variant bits @@ -73,7 +67,7 @@ trait VariantTrait // three characters (three most-significant bits) to determine the // variant. $binary = str_pad( - decbin($parts[5]), + decbin((int) $parts[5]), 16, '0', STR_PAD_LEFT @@ -82,13 +76,15 @@ trait VariantTrait $msb = substr($binary, 0, 3); if ($msb === '111') { - return Uuid::RESERVED_FUTURE; + $variant = Uuid::RESERVED_FUTURE; } elseif ($msb === '110') { - return Uuid::RESERVED_MICROSOFT; - } elseif (str_starts_with($msb, '10')) { - return Uuid::RFC_4122; + $variant = Uuid::RESERVED_MICROSOFT; + } elseif (strpos($msb, '10') === 0) { + $variant = Uuid::RFC_4122; + } else { + $variant = Uuid::RESERVED_NCS; } - return Uuid::RESERVED_NCS; + return $variant; } } |