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

Breadcrumb

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

function UnixTimeGenerator::randomize

2 calls to UnixTimeGenerator::randomize()
UnixTimeGenerator::generate in vendor/ramsey/uuid/src/Generator/UnixTimeGenerator.php
@inheritDoc
UnixTimeGenerator::increment in vendor/ramsey/uuid/src/Generator/UnixTimeGenerator.php
Special thanks to Nicolas Grekas for sharing the following information:

File

vendor/ramsey/uuid/src/Generator/UnixTimeGenerator.php, line 92

Class

UnixTimeGenerator
UnixTimeGenerator generates bytes that combine a 48-bit timestamp in milliseconds since the Unix Epoch with 80 random bits

Namespace

Ramsey\Uuid\Generator

Code

private function randomize(string $time) : void {
    if (self::$seed === null) {
        $seed = $this->randomGenerator
            ->generate(16);
        self::$seed = $seed;
    }
    else {
        $seed = $this->randomGenerator
            ->generate(10);
    }
    
    /** @var int[] $rand */
    $rand = unpack('n*', $seed);
    $rand[1] &= 0x3ff;
    self::$rand = $rand;
    self::$time = $time;
}

API Navigation

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