aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/ramsey/uuid/src/Rfc4122/VariantTrait.php
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2022-10-11 18:18:57 +0000
committerMario <mario@mariovavti.com>2022-10-11 18:18:57 +0000
commit5e5f0aa955d86743a14531bed98501b59140ab1f (patch)
treef8a7bbff876adf28d03cc005b8e0a0602886ffc8 /vendor/ramsey/uuid/src/Rfc4122/VariantTrait.php
parentf9a4c53e3feb07e5319b110b25b4746ae839c420 (diff)
downloadvolse-hubzilla-5e5f0aa955d86743a14531bed98501b59140ab1f.tar.gz
volse-hubzilla-5e5f0aa955d86743a14531bed98501b59140ab1f.tar.bz2
volse-hubzilla-5e5f0aa955d86743a14531bed98501b59140ab1f.zip
update composer libs
Diffstat (limited to 'vendor/ramsey/uuid/src/Rfc4122/VariantTrait.php')
-rw-r--r--vendor/ramsey/uuid/src/Rfc4122/VariantTrait.php24
1 files changed, 14 insertions, 10 deletions
diff --git a/vendor/ramsey/uuid/src/Rfc4122/VariantTrait.php b/vendor/ramsey/uuid/src/Rfc4122/VariantTrait.php
index 4c981658f..1041de51e 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,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;
}
}