function UuidFactory::uuid6
Overrides UuidFactoryInterface::uuid6
File
-
vendor/
ramsey/ uuid/ src/ UuidFactory.php, line 374
Class
Namespace
Ramsey\UuidCode
public function uuid6(?Hexadecimal $node = null, ?int $clockSeq = null) : UuidInterface {
$nodeHex = $node ? $node->toString() : null;
$bytes = $this->timeGenerator
->generate($nodeHex, $clockSeq);
// Rearrange the bytes, according to the UUID version 6 specification.
$v6 = $bytes[6] . $bytes[7] . $bytes[4] . $bytes[5] . $bytes[0] . $bytes[1] . $bytes[2] . $bytes[3];
$v6 = bin2hex($v6);
// Drop the first four bits, while adding an empty four bits for the
// version field. This allows us to reconstruct the correct time from
// the bytes of this UUID.
$v6Bytes = hex2bin(substr($v6, 1, 12) . '0' . substr($v6, -3));
$v6Bytes .= substr($bytes, 8);
return $this->uuidFromBytesAndVersion($v6Bytes, Uuid::UUID_TYPE_REORDERED_TIME);
}