Aggiornato Composer
This commit is contained in:
24
vendor/ramsey/uuid/src/Rfc4122/VariantTrait.php
vendored
24
vendor/ramsey/uuid/src/Rfc4122/VariantTrait.php
vendored
@@ -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,7 +58,13 @@ trait VariantTrait
|
||||
throw new InvalidBytesException('Invalid number of bytes');
|
||||
}
|
||||
|
||||
/** @var array $parts */
|
||||
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 */
|
||||
$parts = unpack('n*', $this->getBytes());
|
||||
|
||||
// $parts[5] is a 16-bit, unsigned integer containing the variant bits
|
||||
@@ -67,7 +73,7 @@ trait VariantTrait
|
||||
// three characters (three most-significant bits) to determine the
|
||||
// variant.
|
||||
$binary = str_pad(
|
||||
decbin((int) $parts[5]),
|
||||
decbin($parts[5]),
|
||||
16,
|
||||
'0',
|
||||
STR_PAD_LEFT
|
||||
@@ -76,15 +82,13 @@ trait VariantTrait
|
||||
$msb = substr($binary, 0, 3);
|
||||
|
||||
if ($msb === '111') {
|
||||
$variant = Uuid::RESERVED_FUTURE;
|
||||
return Uuid::RESERVED_FUTURE;
|
||||
} elseif ($msb === '110') {
|
||||
$variant = Uuid::RESERVED_MICROSOFT;
|
||||
} elseif (strpos($msb, '10') === 0) {
|
||||
$variant = Uuid::RFC_4122;
|
||||
} else {
|
||||
$variant = Uuid::RESERVED_NCS;
|
||||
return Uuid::RESERVED_MICROSOFT;
|
||||
} elseif (str_starts_with($msb, '10')) {
|
||||
return Uuid::RFC_4122;
|
||||
}
|
||||
|
||||
return $variant;
|
||||
return Uuid::RESERVED_NCS;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user