Documentation

UuidFactory
in package
implements UuidFactoryInterface

Interfaces, Classes and Traits

UuidFactoryInterface
UuidFactoryInterface defines common functionality all `UuidFactory` instances must implement

Table of Contents

$codec  : CodecInterface
$nodeProvider  : NodeProviderInterface
$numberConverter  : NumberConverterInterface
$randomGenerator  : RandomGeneratorInterface
$timeGenerator  : TimeGeneratorInterface
$uuidBuilder  : UuidBuilderInterface
__construct()  : mixed
Constructs a `UuidFactory` for creating `Ramsey\Uuid\UuidInterface` instances
fromBytes()  : UuidInterface
Creates a UUID from a byte string.
fromInteger()  : UuidInterface
Creates a `Uuid` from an integer representation
fromString()  : UuidInterface
Creates a UUID from the string standard representation
getCodec()  : CodecInterface
Returns the UUID coder-decoder used by this factory
getNodeProvider()  : NodeProviderInterface
Returns the system node ID provider used by this factory
getNumberConverter()  : NumberConverterInterface
Returns the number converter used by this factory
getRandomGenerator()  : RandomGeneratorInterface
Returns the random UUID generator used by this factory
getTimeGenerator()  : TimeGeneratorInterface
Returns the time-based UUID generator used by this factory
getUuidBuilder()  : UuidBuilderInterface
Returns the UUID builder this factory uses when creating `Uuid` instances
setCodec()  : mixed
Sets the UUID coder-decoder used by this factory
setNumberConverter()  : mixed
Sets the number converter this factory will use
setRandomGenerator()  : mixed
Sets the random UUID generator this factory will use to generate version 4 UUIDs
setTimeGenerator()  : mixed
Sets the time-based UUID generator this factory will use to generate version 1 UUIDs
setUuidBuilder()  : mixed
Sets the UUID builder this factory will use when creating `Uuid` instances
uuid()  : UuidInterface
Returns a `Uuid`
uuid1()  : UuidInterface
Generate a version 1 UUID from a host ID, sequence number, and the current time.
uuid3()  : UuidInterface
Generate a version 3 UUID based on the MD5 hash of a namespace identifier (which is a UUID) and a name (which is a string).
uuid4()  : UuidInterface
Generate a version 4 (random) UUID.
uuid5()  : UuidInterface
Generate a version 5 UUID based on the SHA-1 hash of a namespace identifier (which is a UUID) and a name (which is a string).
uuidFromHashedName()  : UuidInterface
Returns a `Uuid` created from `$hash` with the version field set to `$version` and the variant field set for RFC 4122
uuidFromNsAndName()  : UuidInterface
Returns a version 3 or 5 namespaced `Uuid`

Properties

Methods

__construct()

Constructs a `UuidFactory` for creating `Ramsey\Uuid\UuidInterface` instances

public __construct([FeatureSet $features = null ]) : mixed
Parameters
$features : FeatureSet = null

A set of features for use when creating UUIDs

Return values
mixed —

fromBytes()

Creates a UUID from a byte string.

public fromBytes(mixed $bytes) : UuidInterface
Parameters
$bytes : mixed

A 16-byte string representation of a UUID

Tags
inheritdoc
Return values
UuidInterface —

fromInteger()

Creates a `Uuid` from an integer representation

public fromInteger(mixed $integer) : UuidInterface
Parameters
$integer : mixed

The integer to use when creating a Uuid from an integer; may be of any type understood by the configured number converter

Tags
inheritdoc
Return values
UuidInterface —

fromString()

Creates a UUID from the string standard representation

public fromString(mixed $uuid) : UuidInterface
Parameters
$uuid : mixed

A string representation of a UUID

Tags
inheritdoc
Return values
UuidInterface —

uuid()

Returns a `Uuid`

public uuid(array<string|int, mixed> $fields) : UuidInterface

Uses the configured builder and codec and the provided array of hexadecimal value UUID fields to construct a Uuid object.

Parameters
$fields : array<string|int, mixed>

An array of fields from which to construct a UUID; see UuidInterface::getFieldsHex() for array structure.

Return values
UuidInterface —

uuid1()

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

public uuid1([mixed $node = null ][, mixed $clockSeq = null ]) : UuidInterface
Parameters
$node : mixed = null

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

$clockSeq : mixed = 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
inheritdoc
Return values
UuidInterface —

uuid3()

Generate a version 3 UUID based on the MD5 hash of a namespace identifier (which is a UUID) and a name (which is a string).

public uuid3(mixed $ns, mixed $name) : UuidInterface
Parameters
$ns : mixed

The UUID namespace in which to create the named UUID

$name : mixed

The name to create a UUID for

Tags
inheritdoc
Return values
UuidInterface —

uuid5()

Generate a version 5 UUID based on the SHA-1 hash of a namespace identifier (which is a UUID) and a name (which is a string).

public uuid5(mixed $ns, mixed $name) : UuidInterface
Parameters
$ns : mixed

The UUID namespace in which to create the named UUID

$name : mixed

The name to create a UUID for

Tags
inheritdoc
Return values
UuidInterface —

uuidFromHashedName()

Returns a `Uuid` created from `$hash` with the version field set to `$version` and the variant field set for RFC 4122

protected uuidFromHashedName(string $hash, int $version) : UuidInterface
Parameters
$hash : string

The hash to use when creating the UUID

$version : int

The UUID version to set for this hash (1, 3, 4, or 5)

Return values
UuidInterface —

uuidFromNsAndName()

Returns a version 3 or 5 namespaced `Uuid`

protected uuidFromNsAndName(string|UuidInterface $ns, string $name, int $version, string $hashFunction) : UuidInterface
Parameters
$ns : string|UuidInterface

The UUID namespace to use

$name : string

The string to hash together with the namespace

$version : int

The version of UUID to create (3 or 5)

$hashFunction : string

The hash function to use when hashing together the namespace and name

Tags
throws
InvalidUuidStringException
Return values
UuidInterface —

Search results