aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/ramsey/uuid/src/Generator
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/Generator
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/Generator')
-rw-r--r--vendor/ramsey/uuid/src/Generator/CombGenerator.php20
-rw-r--r--vendor/ramsey/uuid/src/Generator/DceSecurityGenerator.php27
-rw-r--r--vendor/ramsey/uuid/src/Generator/DefaultTimeGenerator.php28
-rw-r--r--vendor/ramsey/uuid/src/Generator/PeclUuidNameGenerator.php21
-rw-r--r--vendor/ramsey/uuid/src/Generator/RandomGeneratorInterface.php2
-rw-r--r--vendor/ramsey/uuid/src/Generator/RandomLibAdapter.php5
-rw-r--r--vendor/ramsey/uuid/src/Generator/TimeGeneratorFactory.php24
-rw-r--r--vendor/ramsey/uuid/src/Generator/UnixTimeGenerator.php52
8 files changed, 78 insertions, 101 deletions
diff --git a/vendor/ramsey/uuid/src/Generator/CombGenerator.php b/vendor/ramsey/uuid/src/Generator/CombGenerator.php
index 25b7988ec..0e8870608 100644
--- a/vendor/ramsey/uuid/src/Generator/CombGenerator.php
+++ b/vendor/ramsey/uuid/src/Generator/CombGenerator.php
@@ -61,22 +61,10 @@ class CombGenerator implements RandomGeneratorInterface
{
public const TIMESTAMP_BYTES = 6;
- /**
- * @var RandomGeneratorInterface
- */
- private $randomGenerator;
-
- /**
- * @var NumberConverterInterface
- */
- private $converter;
-
public function __construct(
- RandomGeneratorInterface $generator,
- NumberConverterInterface $numberConverter
+ private RandomGeneratorInterface $generator,
+ private NumberConverterInterface $numberConverter
) {
- $this->converter = $numberConverter;
- $this->randomGenerator = $generator;
}
/**
@@ -95,11 +83,11 @@ class CombGenerator implements RandomGeneratorInterface
$hash = '';
if (self::TIMESTAMP_BYTES > 0 && $length > self::TIMESTAMP_BYTES) {
- $hash = $this->randomGenerator->generate($length - self::TIMESTAMP_BYTES);
+ $hash = $this->generator->generate($length - self::TIMESTAMP_BYTES);
}
$lsbTime = str_pad(
- $this->converter->toHex($this->timestamp()),
+ $this->numberConverter->toHex($this->timestamp()),
self::TIMESTAMP_BYTES * 2,
'0',
STR_PAD_LEFT
diff --git a/vendor/ramsey/uuid/src/Generator/DceSecurityGenerator.php b/vendor/ramsey/uuid/src/Generator/DceSecurityGenerator.php
index aca8c5db7..37ba78131 100644
--- a/vendor/ramsey/uuid/src/Generator/DceSecurityGenerator.php
+++ b/vendor/ramsey/uuid/src/Generator/DceSecurityGenerator.php
@@ -52,29 +52,11 @@ class DceSecurityGenerator implements DceSecurityGeneratorInterface
*/
private const CLOCK_SEQ_LOW = 0;
- /**
- * @var NumberConverterInterface
- */
- private $numberConverter;
-
- /**
- * @var TimeGeneratorInterface
- */
- private $timeGenerator;
-
- /**
- * @var DceSecurityProviderInterface
- */
- private $dceSecurityProvider;
-
public function __construct(
- NumberConverterInterface $numberConverter,
- TimeGeneratorInterface $timeGenerator,
- DceSecurityProviderInterface $dceSecurityProvider
+ private NumberConverterInterface $numberConverter,
+ private TimeGeneratorInterface $timeGenerator,
+ private DceSecurityProviderInterface $dceSecurityProvider
) {
- $this->numberConverter = $numberConverter;
- $this->timeGenerator = $timeGenerator;
- $this->dceSecurityProvider = $dceSecurityProvider;
}
public function generate(
@@ -153,8 +135,7 @@ class DceSecurityGenerator implements DceSecurityGeneratorInterface
// Replace bytes in the time-based UUID with DCE Security values.
$bytes = substr_replace($bytes, $identifierBytes, 0, 4);
- $bytes = substr_replace($bytes, $domainByte, 9, 1);
- return $bytes;
+ return substr_replace($bytes, $domainByte, 9, 1);
}
}
diff --git a/vendor/ramsey/uuid/src/Generator/DefaultTimeGenerator.php b/vendor/ramsey/uuid/src/Generator/DefaultTimeGenerator.php
index d245c7bcc..a1b39b04a 100644
--- a/vendor/ramsey/uuid/src/Generator/DefaultTimeGenerator.php
+++ b/vendor/ramsey/uuid/src/Generator/DefaultTimeGenerator.php
@@ -40,29 +40,11 @@ use const STR_PAD_LEFT;
*/
class DefaultTimeGenerator implements TimeGeneratorInterface
{
- /**
- * @var NodeProviderInterface
- */
- private $nodeProvider;
-
- /**
- * @var TimeConverterInterface
- */
- private $timeConverter;
-
- /**
- * @var TimeProviderInterface
- */
- private $timeProvider;
-
public function __construct(
- NodeProviderInterface $nodeProvider,
- TimeConverterInterface $timeConverter,
- TimeProviderInterface $timeProvider
+ private NodeProviderInterface $nodeProvider,
+ private TimeConverterInterface $timeConverter,
+ private TimeProviderInterface $timeProvider
) {
- $this->nodeProvider = $nodeProvider;
- $this->timeConverter = $timeConverter;
- $this->timeProvider = $timeProvider;
}
/**
@@ -121,13 +103,13 @@ class DefaultTimeGenerator implements TimeGeneratorInterface
* Uses the node provider given when constructing this instance to get
* the node ID (usually a MAC address)
*
- * @param string|int|null $node A node value that may be used to override the node provider
+ * @param int|string|null $node A node value that may be used to override the node provider
*
* @return string 6-byte binary string representation of the node
*
* @throws InvalidArgumentException
*/
- private function getValidNode($node): string
+ private function getValidNode(int | string | null $node): string
{
if ($node === null) {
$node = $this->nodeProvider->getNode();
diff --git a/vendor/ramsey/uuid/src/Generator/PeclUuidNameGenerator.php b/vendor/ramsey/uuid/src/Generator/PeclUuidNameGenerator.php
index 3780c5c60..6a6d1aec3 100644
--- a/vendor/ramsey/uuid/src/Generator/PeclUuidNameGenerator.php
+++ b/vendor/ramsey/uuid/src/Generator/PeclUuidNameGenerator.php
@@ -33,21 +33,16 @@ class PeclUuidNameGenerator implements NameGeneratorInterface
/** @psalm-pure */
public function generate(UuidInterface $ns, string $name, string $hashAlgorithm): string
{
- switch ($hashAlgorithm) {
- case 'md5':
- $uuid = uuid_generate_md5($ns->toString(), $name);
-
- break;
- case 'sha1':
- $uuid = uuid_generate_sha1($ns->toString(), $name);
-
- break;
- default:
- throw new NameException(sprintf(
+ $uuid = match ($hashAlgorithm) {
+ 'md5' => uuid_generate_md5($ns->toString(), $name),
+ 'sha1' => uuid_generate_sha1($ns->toString(), $name),
+ default => throw new NameException(
+ sprintf(
'Unable to hash namespace and name with algorithm \'%s\'',
$hashAlgorithm
- ));
- }
+ )
+ ),
+ };
return uuid_parse($uuid);
}
diff --git a/vendor/ramsey/uuid/src/Generator/RandomGeneratorInterface.php b/vendor/ramsey/uuid/src/Generator/RandomGeneratorInterface.php
index 5c83cb4d8..1180b9764 100644
--- a/vendor/ramsey/uuid/src/Generator/RandomGeneratorInterface.php
+++ b/vendor/ramsey/uuid/src/Generator/RandomGeneratorInterface.php
@@ -22,7 +22,7 @@ interface RandomGeneratorInterface
/**
* Generates a string of randomized binary data
*
- * @param int $length The number of bytes of random binary data to generate
+ * @param int<1, max> $length The number of bytes of random binary data to generate
*
* @return string A binary string
*/
diff --git a/vendor/ramsey/uuid/src/Generator/RandomLibAdapter.php b/vendor/ramsey/uuid/src/Generator/RandomLibAdapter.php
index 793ccd5a4..fd0ccc8aa 100644
--- a/vendor/ramsey/uuid/src/Generator/RandomLibAdapter.php
+++ b/vendor/ramsey/uuid/src/Generator/RandomLibAdapter.php
@@ -29,10 +29,7 @@ use RandomLib\Generator;
*/
class RandomLibAdapter implements RandomGeneratorInterface
{
- /**
- * @var Generator
- */
- private $generator;
+ private Generator $generator;
/**
* Constructs a RandomLibAdapter
diff --git a/vendor/ramsey/uuid/src/Generator/TimeGeneratorFactory.php b/vendor/ramsey/uuid/src/Generator/TimeGeneratorFactory.php
index 3d55fc4d6..8d06fc3ae 100644
--- a/vendor/ramsey/uuid/src/Generator/TimeGeneratorFactory.php
+++ b/vendor/ramsey/uuid/src/Generator/TimeGeneratorFactory.php
@@ -24,29 +24,11 @@ use Ramsey\Uuid\Provider\TimeProviderInterface;
*/
class TimeGeneratorFactory
{
- /**
- * @var NodeProviderInterface
- */
- private $nodeProvider;
-
- /**
- * @var TimeConverterInterface
- */
- private $timeConverter;
-
- /**
- * @var TimeProviderInterface
- */
- private $timeProvider;
-
public function __construct(
- NodeProviderInterface $nodeProvider,
- TimeConverterInterface $timeConverter,
- TimeProviderInterface $timeProvider
+ private NodeProviderInterface $nodeProvider,
+ private TimeConverterInterface $timeConverter,
+ private TimeProviderInterface $timeProvider
) {
- $this->nodeProvider = $nodeProvider;
- $this->timeConverter = $timeConverter;
- $this->timeProvider = $timeProvider;
}
/**
diff --git a/vendor/ramsey/uuid/src/Generator/UnixTimeGenerator.php b/vendor/ramsey/uuid/src/Generator/UnixTimeGenerator.php
new file mode 100644
index 000000000..1aef8699a
--- /dev/null
+++ b/vendor/ramsey/uuid/src/Generator/UnixTimeGenerator.php
@@ -0,0 +1,52 @@
+<?php
+
+/**
+ * This file is part of the ramsey/uuid library
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ *
+ * @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
+ * @license http://opensource.org/licenses/MIT MIT
+ */
+
+declare(strict_types=1);
+
+namespace Ramsey\Uuid\Generator;
+
+use Ramsey\Uuid\Converter\TimeConverterInterface;
+use Ramsey\Uuid\Provider\TimeProviderInterface;
+
+use function hex2bin;
+
+/**
+ * UnixTimeGenerator generates bytes that combine a 48-bit timestamp in
+ * milliseconds since the Unix Epoch with 80 random bits
+ */
+class UnixTimeGenerator implements TimeGeneratorInterface
+{
+ public function __construct(
+ private TimeConverterInterface $timeConverter,
+ private TimeProviderInterface $timeProvider,
+ private RandomGeneratorInterface $randomGenerator
+ ) {
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function generate($node = null, ?int $clockSeq = null): string
+ {
+ // Generate 10 random bytes to append to the string returned, since our
+ // time bytes will consist of 6 bytes.
+ $random = $this->randomGenerator->generate(10);
+
+ $time = $this->timeProvider->getTime();
+ $unixTimeHex = $this->timeConverter->calculateTime(
+ $time->getSeconds()->toString(),
+ $time->getMicroseconds()->toString(),
+ );
+
+ return hex2bin($unixTimeHex->toString()) . $random;
+ }
+}