Skip to content

DefaultTimeGenerator

DefaultTimeGenerator generates strings of binary data based on a node ID, clock sequence, and the current time

Properties

nodeProvider

private \Ramsey\Uuid\Provider\NodeProviderInterface $nodeProvider

timeConverter

private \Ramsey\Uuid\Converter\TimeConverterInterface $timeConverter

timeProvider

private \Ramsey\Uuid\Provider\TimeProviderInterface $timeProvider

Methods

__construct

public __construct(\Ramsey\Uuid\Provider\NodeProviderInterface $nodeProvider, \Ramsey\Uuid\Converter\TimeConverterInterface $timeConverter, \Ramsey\Uuid\Provider\TimeProviderInterface $timeProvider): mixed

Parameters:

Parameter Type Description
$nodeProvider \Ramsey\Uuid\Provider\NodeProviderInterface
$timeConverter \Ramsey\Uuid\Converter\TimeConverterInterface
$timeProvider \Ramsey\Uuid\Provider\TimeProviderInterface

generate

Generate a binary string from a node ID, clock sequence, and current time

public generate(mixed $node = null, ?int $clockSeq = null): string

Parameters:

Parameter Type Description
$node mixed A 48-bit number representing the
hardware address; this number may be represented as an integer or a
hexadecimal string
$clockSeq ?int A 14-bit number used to help avoid duplicates
that could arise when the clock is set backwards in time or if the
node ID changes

Return Value:

A binary string

Throws:

if the parameters contain invalid values

if random_int() throws an exception/error


getValidNode

Uses the node provider given when constructing this instance to get the node ID (usually a MAC address)

private getValidNode(int|string|null $node): string

Parameters:

Parameter Type Description
$node int|string|null A node value that may be used to override the node provider

Return Value:

6-byte binary string representation of the node

Throws:



Automatically generated on 2025-03-18