diff options
author | Mario <mario@mariovavti.com> | 2023-05-30 08:36:17 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2023-05-30 08:36:17 +0000 |
commit | b9812ba06ac16899df2a25f0abf25962ae3273f2 (patch) | |
tree | 35762d0183f5b0c6d866b00cdeebfbae595cfa56 /vendor/ramsey/uuid/src/Codec | |
parent | bc6aded074156ec81084334a4d6aa58bc0f37a68 (diff) | |
download | volse-hubzilla-b9812ba06ac16899df2a25f0abf25962ae3273f2.tar.gz volse-hubzilla-b9812ba06ac16899df2a25f0abf25962ae3273f2.tar.bz2 volse-hubzilla-b9812ba06ac16899df2a25f0abf25962ae3273f2.zip |
update composer libs
Diffstat (limited to 'vendor/ramsey/uuid/src/Codec')
-rw-r--r-- | vendor/ramsey/uuid/src/Codec/GuidStringCodec.php | 21 | ||||
-rw-r--r-- | vendor/ramsey/uuid/src/Codec/StringCodec.php | 27 |
2 files changed, 34 insertions, 14 deletions
diff --git a/vendor/ramsey/uuid/src/Codec/GuidStringCodec.php b/vendor/ramsey/uuid/src/Codec/GuidStringCodec.php index f11e9d50a..04872e0bc 100644 --- a/vendor/ramsey/uuid/src/Codec/GuidStringCodec.php +++ b/vendor/ramsey/uuid/src/Codec/GuidStringCodec.php @@ -18,6 +18,7 @@ use Ramsey\Uuid\Guid\Guid; use Ramsey\Uuid\UuidInterface; use function bin2hex; +use function sprintf; use function substr; /** @@ -29,6 +30,26 @@ use function substr; */ class GuidStringCodec extends StringCodec { + public function encode(UuidInterface $uuid): string + { + $hex = bin2hex($uuid->getFields()->getBytes()); + + /** @var non-empty-string */ + return sprintf( + '%02s%02s%02s%02s-%02s%02s-%02s%02s-%04s-%012s', + substr($hex, 6, 2), + substr($hex, 4, 2), + substr($hex, 2, 2), + substr($hex, 0, 2), + substr($hex, 10, 2), + substr($hex, 8, 2), + substr($hex, 14, 2), + substr($hex, 12, 2), + substr($hex, 16, 4), + substr($hex, 20), + ); + } + public function decode(string $encodedUuid): UuidInterface { $bytes = $this->getBytes($encodedUuid); diff --git a/vendor/ramsey/uuid/src/Codec/StringCodec.php b/vendor/ramsey/uuid/src/Codec/StringCodec.php index 4b6e4e5b9..95f38d2e8 100644 --- a/vendor/ramsey/uuid/src/Codec/StringCodec.php +++ b/vendor/ramsey/uuid/src/Codec/StringCodec.php @@ -17,12 +17,13 @@ namespace Ramsey\Uuid\Codec; use Ramsey\Uuid\Builder\UuidBuilderInterface; use Ramsey\Uuid\Exception\InvalidArgumentException; use Ramsey\Uuid\Exception\InvalidUuidStringException; -use Ramsey\Uuid\Rfc4122\FieldsInterface; use Ramsey\Uuid\Uuid; use Ramsey\Uuid\UuidInterface; +use function bin2hex; use function hex2bin; use function implode; +use function sprintf; use function str_replace; use function strlen; use function substr; @@ -47,19 +48,17 @@ class StringCodec implements CodecInterface public function encode(UuidInterface $uuid): string { - /** @var FieldsInterface $fields */ - $fields = $uuid->getFields(); - - return $fields->getTimeLow()->toString() - . '-' - . $fields->getTimeMid()->toString() - . '-' - . $fields->getTimeHiAndVersion()->toString() - . '-' - . $fields->getClockSeqHiAndReserved()->toString() - . $fields->getClockSeqLow()->toString() - . '-' - . $fields->getNode()->toString(); + $hex = bin2hex($uuid->getFields()->getBytes()); + + /** @var non-empty-string */ + return sprintf( + '%08s-%04s-%04s-%04s-%012s', + substr($hex, 0, 8), + substr($hex, 8, 4), + substr($hex, 12, 4), + substr($hex, 16, 4), + substr($hex, 20), + ); } /** |