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
$codec
private
CodecInterface
$codec
= null
$nodeProvider
private
NodeProviderInterface
$nodeProvider
= null
$numberConverter
private
NumberConverterInterface
$numberConverter
= null
$randomGenerator
private
RandomGeneratorInterface
$randomGenerator
= null
$timeGenerator
private
TimeGeneratorInterface
$timeGenerator
= null
$uuidBuilder
private
UuidBuilderInterface
$uuidBuilder
= null
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
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
Uuidfrom an integer; may be of any type understood by the configured number converter
Tags
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
Return values
UuidInterface —getCodec()
Returns the UUID coder-decoder used by this factory
public
getCodec() : CodecInterface
Return values
CodecInterface —getNodeProvider()
Returns the system node ID provider used by this factory
public
getNodeProvider() : NodeProviderInterface
Return values
NodeProviderInterface —getNumberConverter()
Returns the number converter used by this factory
public
getNumberConverter() : NumberConverterInterface
Return values
NumberConverterInterface —getRandomGenerator()
Returns the random UUID generator used by this factory
public
getRandomGenerator() : RandomGeneratorInterface
Return values
RandomGeneratorInterface —getTimeGenerator()
Returns the time-based UUID generator used by this factory
public
getTimeGenerator() : TimeGeneratorInterface
Return values
TimeGeneratorInterface —getUuidBuilder()
Returns the UUID builder this factory uses when creating `Uuid` instances
public
getUuidBuilder() : UuidBuilderInterface
Return values
UuidBuilderInterface —$builder
setCodec()
Sets the UUID coder-decoder used by this factory
public
setCodec(CodecInterface $codec) : mixed
Parameters
- $codec : CodecInterface
Return values
mixed —setNumberConverter()
Sets the number converter this factory will use
public
setNumberConverter(NumberConverterInterface $converter) : mixed
Parameters
- $converter : NumberConverterInterface
Return values
mixed —setRandomGenerator()
Sets the random UUID generator this factory will use to generate version 4 UUIDs
public
setRandomGenerator(RandomGeneratorInterface $generator) : mixed
Parameters
- $generator : RandomGeneratorInterface
Return values
mixed —setTimeGenerator()
Sets the time-based UUID generator this factory will use to generate version 1 UUIDs
public
setTimeGenerator(TimeGeneratorInterface $generator) : mixed
Parameters
- $generator : TimeGeneratorInterface
Return values
mixed —setUuidBuilder()
Sets the UUID builder this factory will use when creating `Uuid` instances
public
setUuidBuilder(UuidBuilderInterface $builder) : mixed
Parameters
- $builder : UuidBuilderInterface
Return values
mixed —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
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
Return values
UuidInterface —uuid4()
Generate a version 4 (random) UUID.
public
uuid4() : UuidInterface
Tags
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
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