Documentation

DefaultTimeGenerator
in package
implements TimeGeneratorInterface

DefaultTimeGenerator provides functionality to generate strings of binary data for version 1 UUIDs based on a host ID, sequence number, and the current time

Interfaces, Classes and Traits

TimeGeneratorInterface
TimeGeneratorInterface provides functionality to generate strings of binary data for version 1 UUIDs based on a host ID, sequence number, and the current time

Table of Contents

$nodeProvider  : NodeProviderInterface
$timeConverter  : TimeConverterInterface
$timeProvider  : TimeProviderInterface
__construct()  : mixed
Constructs a `DefaultTimeGenerator` using a node provider, time converter, and time provider
generate()  : string
Generate a version 1 UUID from a host ID, sequence number, and the current time
getValidNode()  : string
Uses the node provider given when constructing this instance to get the node ID (usually a MAC address)

Properties

Methods

generate()

Generate a version 1 UUID from a host ID, sequence number, and the current time

public generate([int|string $node = null ][, int $clockSeq = null ]) : string

If $node is not given, we will attempt to obtain the local hardware address. If $clockSeq is given, it is used as the sequence number; otherwise a random 14-bit sequence number is chosen.

Parameters
$node : int|string = null

A 48-bit number representing the hardware address This number may be represented as an integer or a hexadecimal string.

$clockSeq : int = null

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.

Tags
throws
UnsatisfiedDependencyException

if called on a 32-bit system and Moontoast\Math\BigNumber is not present

throws
InvalidArgumentException
throws
Exception

if it was not possible to gather sufficient entropy

Return values
string

A binary string

getValidNode()

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

protected getValidNode(string|int $node) : string
Parameters
$node : string|int

A node value that may be used to override the node provider

Tags
throws
InvalidArgumentException
throws
Exception
Return values
string

Hexadecimal representation of the node ID

Search results