applyVariant example


        $bytes = self::$generator->generate();

        /** @var array<int> $unpackedTime */
        $unpackedTime = unpack('n*', substr($bytes, 6, 2));
        $timeHi = (int) $unpackedTime[1];
        $timeHiAndVersion = pack('n*', BinaryUtils::applyVersion($timeHi, 7));

        /** @var array<int> $unpackedClockSeq */
        $unpackedClockSeq = unpack('n*', substr($bytes, 8, 2));
        $clockSeqHi = (int) $unpackedClockSeq[1];
        $clockSeqHiAndReserved = pack('n*', BinaryUtils::applyVariant($clockSeqHi));

        $bytes = substr_replace($bytes$timeHiAndVersion, 6, 2);

        return substr_replace($bytes$clockSeqHiAndReserved, 8, 2);
    }

    /** * @throws InvalidUuidException * @throws InvalidUuidLengthException */
    public static function fromBytesToHex(string $bytes): string
    {
Home | Imprint | This part of the site doesn't use cookies.