aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/ramsey/uuid/src/UuidFactory.php
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2022-10-11 18:29:06 +0000
committerMario <mario@mariovavti.com>2022-10-11 18:29:06 +0000
commitccd826f63a7a4c7e442fab8a70d9c4c84808b417 (patch)
treefbbde69114acba764cf6b735433c53e099fd19c5 /vendor/ramsey/uuid/src/UuidFactory.php
parent5e5f0aa955d86743a14531bed98501b59140ab1f (diff)
downloadvolse-hubzilla-ccd826f63a7a4c7e442fab8a70d9c4c84808b417.tar.gz
volse-hubzilla-ccd826f63a7a4c7e442fab8a70d9c4c84808b417.tar.bz2
volse-hubzilla-ccd826f63a7a4c7e442fab8a70d9c4c84808b417.zip
Revert "update composer libs"
This reverts commit 5e5f0aa955d86743a14531bed98501b59140ab1f.
Diffstat (limited to 'vendor/ramsey/uuid/src/UuidFactory.php')
-rw-r--r--vendor/ramsey/uuid/src/UuidFactory.php122
1 files changed, 59 insertions, 63 deletions
diff --git a/vendor/ramsey/uuid/src/UuidFactory.php b/vendor/ramsey/uuid/src/UuidFactory.php
index ab730f741..6f2cea061 100644
--- a/vendor/ramsey/uuid/src/UuidFactory.php
+++ b/vendor/ramsey/uuid/src/UuidFactory.php
@@ -18,16 +18,13 @@ use DateTimeInterface;
use Ramsey\Uuid\Builder\UuidBuilderInterface;
use Ramsey\Uuid\Codec\CodecInterface;
use Ramsey\Uuid\Converter\NumberConverterInterface;
-use Ramsey\Uuid\Converter\Time\UnixTimeConverter;
use Ramsey\Uuid\Converter\TimeConverterInterface;
use Ramsey\Uuid\Generator\DceSecurityGeneratorInterface;
use Ramsey\Uuid\Generator\DefaultTimeGenerator;
use Ramsey\Uuid\Generator\NameGeneratorInterface;
use Ramsey\Uuid\Generator\RandomGeneratorInterface;
use Ramsey\Uuid\Generator\TimeGeneratorInterface;
-use Ramsey\Uuid\Generator\UnixTimeGenerator;
use Ramsey\Uuid\Lazy\LazyUuidFromString;
-use Ramsey\Uuid\Math\BrickMathCalculator;
use Ramsey\Uuid\Provider\NodeProviderInterface;
use Ramsey\Uuid\Provider\Time\FixedTimeProvider;
use Ramsey\Uuid\Type\Hexadecimal;
@@ -48,26 +45,61 @@ use const STR_PAD_LEFT;
class UuidFactory implements UuidFactoryInterface
{
- private CodecInterface $codec;
- private DceSecurityGeneratorInterface $dceSecurityGenerator;
- private NameGeneratorInterface $nameGenerator;
- private NodeProviderInterface $nodeProvider;
- private NumberConverterInterface $numberConverter;
- private RandomGeneratorInterface $randomGenerator;
- private TimeConverterInterface $timeConverter;
- private TimeGeneratorInterface $timeGenerator;
- private TimeGeneratorInterface $unixTimeGenerator;
- private UuidBuilderInterface $uuidBuilder;
- private ValidatorInterface $validator;
+ /**
+ * @var CodecInterface
+ */
+ private $codec;
+
+ /**
+ * @var DceSecurityGeneratorInterface
+ */
+ private $dceSecurityGenerator;
+
+ /**
+ * @var NameGeneratorInterface
+ */
+ private $nameGenerator;
+
+ /**
+ * @var NodeProviderInterface
+ */
+ private $nodeProvider;
+
+ /**
+ * @var NumberConverterInterface
+ */
+ private $numberConverter;
+
+ /**
+ * @var RandomGeneratorInterface
+ */
+ private $randomGenerator;
+
+ /**
+ * @var TimeConverterInterface
+ */
+ private $timeConverter;
+
+ /**
+ * @var TimeGeneratorInterface
+ */
+ private $timeGenerator;
+
+ /**
+ * @var UuidBuilderInterface
+ */
+ private $uuidBuilder;
/**
- * @var bool whether the feature set was provided from outside, or we can
- * operate under "default" assumptions
+ * @var ValidatorInterface
*/
- private bool $isDefaultFeatureSet;
+ private $validator;
+
+ /** @var bool whether the feature set was provided from outside, or we can operate under "default" assumptions */
+ private $isDefaultFeatureSet;
/**
- * @param FeatureSet|null $features A set of available features in the current environment
+ * @param FeatureSet $features A set of available features in the current environment
*/
public function __construct(?FeatureSet $features = null)
{
@@ -85,7 +117,6 @@ class UuidFactory implements UuidFactoryInterface
$this->timeGenerator = $features->getTimeGenerator();
$this->uuidBuilder = $features->getBuilder();
$this->validator = $features->getValidator();
- $this->unixTimeGenerator = $features->getUnixTimeGenerator();
}
/**
@@ -311,7 +342,7 @@ class UuidFactory implements UuidFactoryInterface
$bytes = $timeGenerator->generate($nodeHex, $clockSeq);
- return $this->uuidFromBytesAndVersion($bytes, Uuid::UUID_TYPE_TIME);
+ return $this->uuidFromBytesAndVersion($bytes, 1);
}
/**
@@ -321,7 +352,7 @@ class UuidFactory implements UuidFactoryInterface
{
$bytes = $this->timeGenerator->generate($node, $clockSeq);
- return $this->uuidFromBytesAndVersion($bytes, Uuid::UUID_TYPE_TIME);
+ return $this->uuidFromBytesAndVersion($bytes, 1);
}
public function uuid2(
@@ -337,7 +368,7 @@ class UuidFactory implements UuidFactoryInterface
$clockSeq
);
- return $this->uuidFromBytesAndVersion($bytes, Uuid::UUID_TYPE_DCE_SECURITY);
+ return $this->uuidFromBytesAndVersion($bytes, 2);
}
/**
@@ -346,14 +377,14 @@ class UuidFactory implements UuidFactoryInterface
*/
public function uuid3($ns, string $name): UuidInterface
{
- return $this->uuidFromNsAndName($ns, $name, Uuid::UUID_TYPE_HASH_MD5, 'md5');
+ return $this->uuidFromNsAndName($ns, $name, 3, 'md5');
}
public function uuid4(): UuidInterface
{
$bytes = $this->randomGenerator->generate(16);
- return $this->uuidFromBytesAndVersion($bytes, Uuid::UUID_TYPE_RANDOM);
+ return $this->uuidFromBytesAndVersion($bytes, 4);
}
/**
@@ -362,7 +393,7 @@ class UuidFactory implements UuidFactoryInterface
*/
public function uuid5($ns, string $name): UuidInterface
{
- return $this->uuidFromNsAndName($ns, $name, Uuid::UUID_TYPE_HASH_SHA1, 'sha1');
+ return $this->uuidFromNsAndName($ns, $name, 5, 'sha1');
}
public function uuid6(?Hexadecimal $node = null, ?int $clockSeq = null): UuidInterface
@@ -381,38 +412,7 @@ class UuidFactory implements UuidFactoryInterface
$v6Bytes = hex2bin(substr($v6, 1, 12) . '0' . substr($v6, -3));
$v6Bytes .= substr($bytes, 8);
- return $this->uuidFromBytesAndVersion($v6Bytes, Uuid::UUID_TYPE_REORDERED_TIME);
- }
-
- /**
- * Returns a version 7 (Unix Epoch time) UUID
- *
- * @param DateTimeInterface|null $dateTime An optional date/time from which
- * to create the version 7 UUID. If not provided, the UUID is generated
- * using the current date/time.
- *
- * @return UuidInterface A UuidInterface instance that represents a
- * version 7 UUID
- */
- public function uuid7(?DateTimeInterface $dateTime = null): UuidInterface
- {
- if ($dateTime !== null) {
- $timeProvider = new FixedTimeProvider(
- new Time($dateTime->format('U'), $dateTime->format('u'))
- );
-
- $timeGenerator = new UnixTimeGenerator(
- new UnixTimeConverter(new BrickMathCalculator()),
- $timeProvider,
- $this->randomGenerator,
- );
-
- $bytes = $timeGenerator->generate();
- } else {
- $bytes = $this->unixTimeGenerator->generate();
- }
-
- return $this->uuidFromBytesAndVersion($bytes, Uuid::UUID_TYPE_UNIX_TIME);
+ return $this->uuidFromBytesAndVersion($v6Bytes, 6);
}
/**
@@ -447,12 +447,8 @@ class UuidFactory implements UuidFactoryInterface
*
* @psalm-pure
*/
- private function uuidFromNsAndName(
- UuidInterface | string $ns,
- string $name,
- int $version,
- string $hashAlgorithm
- ): UuidInterface {
+ private function uuidFromNsAndName($ns, string $name, int $version, string $hashAlgorithm): UuidInterface
+ {
if (!($ns instanceof UuidInterface)) {
$ns = $this->fromString($ns);
}