Ramsey\Uuid\Codec\OrderedTimeCodec::decodeBytes PHP Method

decodeBytes() public method

Decodes an optimized binary representation of a UUID into a UuidInterface object instance
public decodeBytes ( string $bytes ) : Ramsey\Uuid\UuidInterface
$bytes string
return Ramsey\Uuid\UuidInterface
    public function decodeBytes($bytes)
    {
        if (strlen($bytes) !== 16) {
            throw new InvalidArgumentException('$bytes string should contain 16 characters.');
        }
        $hex = unpack('H*', $bytes)[1];
        // Rearrange the fields to their original order
        $hex = substr($hex, 8, 4) . substr($hex, 12, 4) . substr($hex, 4, 4) . substr($hex, 0, 4) . substr($hex, 16);
        return $this->decode($hex);
    }