function StringCodec::encode
Overrides CodecInterface::encode
2 methods override StringCodec::encode()
- GuidStringCodec::encode in vendor/
ramsey/ uuid/ src/ Codec/ GuidStringCodec.php - Returns a hexadecimal string representation of a UuidInterface
- TimestampFirstCombCodec::encode in vendor/
ramsey/ uuid/ src/ Codec/ TimestampFirstCombCodec.php - @psalm-return non-empty-string @psalm-suppress MoreSpecificReturnType we know that the retrieved `string` is never empty @psalm-suppress LessSpecificReturnStatement we know that the retrieved `string` is never empty
File
-
vendor/
ramsey/ uuid/ src/ Codec/ StringCodec.php, line 49
Class
- StringCodec
- StringCodec encodes and decodes RFC 4122 UUIDs
Namespace
Ramsey\Uuid\CodecCode
public function encode(UuidInterface $uuid) : string {
$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));
}