aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/ramsey/uuid/src/Uuid.php
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2021-10-08 12:24:19 +0000
committerMario <mario@mariovavti.com>2021-10-08 12:24:19 +0000
commite6dac085cb1d601da1fc63bfd59d811612fa6ef4 (patch)
treef5b704b613c9c8d347857b4e7f8dd0b19cdd7df3 /vendor/ramsey/uuid/src/Uuid.php
parentf5f357060bf0ebcb0b8352519375953d993437e7 (diff)
downloadvolse-hubzilla-e6dac085cb1d601da1fc63bfd59d811612fa6ef4.tar.gz
volse-hubzilla-e6dac085cb1d601da1fc63bfd59d811612fa6ef4.tar.bz2
volse-hubzilla-e6dac085cb1d601da1fc63bfd59d811612fa6ef4.zip
update composer libs
Diffstat (limited to 'vendor/ramsey/uuid/src/Uuid.php')
-rw-r--r--vendor/ramsey/uuid/src/Uuid.php35
1 files changed, 31 insertions, 4 deletions
diff --git a/vendor/ramsey/uuid/src/Uuid.php b/vendor/ramsey/uuid/src/Uuid.php
index 762dfdbae..945480ba4 100644
--- a/vendor/ramsey/uuid/src/Uuid.php
+++ b/vendor/ramsey/uuid/src/Uuid.php
@@ -23,9 +23,12 @@ use Ramsey\Uuid\Lazy\LazyUuidFromString;
use Ramsey\Uuid\Rfc4122\FieldsInterface as Rfc4122FieldsInterface;
use Ramsey\Uuid\Type\Hexadecimal;
use Ramsey\Uuid\Type\Integer as IntegerObject;
+use ValueError;
+use function assert;
use function bin2hex;
use function preg_match;
+use function sprintf;
use function str_replace;
use function strcmp;
use function strlen;
@@ -238,9 +241,9 @@ class Uuid implements UuidInterface
* ```
* use Ramsey\Uuid\Uuid;
*
- * $timeBasedUuid = Uuid::uuid1();
- * $namespaceMd5Uuid = Uuid::uuid3(Uuid::NAMESPACE_URL, 'http://php.net/');
- * $randomUuid = Uuid::uuid4();
+ * $timeBasedUuid = Uuid::uuid1();
+ * $namespaceMd5Uuid = Uuid::uuid3(Uuid::NAMESPACE_URL, 'http://php.net/');
+ * $randomUuid = Uuid::uuid4();
* $namespaceSha1Uuid = Uuid::uuid5(Uuid::NAMESPACE_URL, 'http://php.net/');
* ```
*
@@ -285,7 +288,15 @@ class Uuid implements UuidInterface
*/
public function serialize(): string
{
- return $this->getBytes();
+ return $this->getFields()->getBytes();
+ }
+
+ /**
+ * @return array{bytes: string}
+ */
+ public function __serialize(): array
+ {
+ return ['bytes' => $this->serialize()];
}
/**
@@ -312,6 +323,20 @@ class Uuid implements UuidInterface
$this->timeConverter = $uuid->timeConverter;
}
+ /**
+ * @param array{bytes: string} $data
+ */
+ public function __unserialize(array $data): void
+ {
+ // @codeCoverageIgnoreStart
+ if (!isset($data['bytes'])) {
+ throw new ValueError(sprintf('%s(): Argument #1 ($data) is invalid', __METHOD__));
+ }
+ // @codeCoverageIgnoreEnd
+
+ $this->unserialize($data['bytes']);
+ }
+
public function compareTo(UuidInterface $other): int
{
$compare = strcmp($this->toString(), $other->toString());
@@ -452,6 +477,8 @@ class Uuid implements UuidInterface
public static function fromString(string $uuid): UuidInterface
{
if (! self::$factoryReplaced && preg_match(LazyUuidFromString::VALID_REGEX, $uuid) === 1) {
+ assert($uuid !== '');
+
return new LazyUuidFromString(strtolower($uuid));
}