Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. UuidFactory.php

function UuidFactory::uuid6

Overrides UuidFactoryInterface::uuid6

File

vendor/ramsey/uuid/src/UuidFactory.php, line 374

Class

UuidFactory

Namespace

Ramsey\Uuid

Code

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);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal