Aggiornato Composer
This commit is contained in:
21
vendor/ramsey/uuid/src/Codec/GuidStringCodec.php
vendored
21
vendor/ramsey/uuid/src/Codec/GuidStringCodec.php
vendored
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user