function StringCodec::getBytes
Returns a byte string of the UUID
3 calls to StringCodec::getBytes()
- GuidStringCodec::decode in vendor/
ramsey/ uuid/ src/ Codec/ GuidStringCodec.php - @inheritDoc
- StringCodec::decode in vendor/
ramsey/ uuid/ src/ Codec/ StringCodec.php - @inheritDoc
- TimestampFirstCombCodec::decode in vendor/
ramsey/ uuid/ src/ Codec/ TimestampFirstCombCodec.php - @inheritDoc
File
-
vendor/
ramsey/ uuid/ src/ Codec/ StringCodec.php, line 107
Class
- StringCodec
- StringCodec encodes and decodes RFC 4122 UUIDs
Namespace
Ramsey\Uuid\CodecCode
protected function getBytes(string $encodedUuid) : string {
$parsedUuid = str_replace([
'urn:',
'uuid:',
'URN:',
'UUID:',
'{',
'}',
'-',
], '', $encodedUuid);
$components = [
substr($parsedUuid, 0, 8),
substr($parsedUuid, 8, 4),
substr($parsedUuid, 12, 4),
substr($parsedUuid, 16, 4),
substr($parsedUuid, 20),
];
if (!Uuid::isValid(implode('-', $components))) {
throw new InvalidUuidStringException('Invalid UUID string: ' . $encodedUuid);
}
return (string) hex2bin($parsedUuid);
}