Documentation

functions.php

This file is part of the ramsey/uuid library

For the full copyright and license information, please view the LICENSE file that was distributed with this source code.

Tags
copyright

Copyright (c) Ben Ramsey ben@benramsey.com

license

http://opensource.org/licenses/MIT MIT phpcs:disable Squiz.Functions.GlobalFunction

Table of Contents

v1()  : non-empty-string
Returns a version 1 (time-based) UUID from a host ID, sequence number, and the current time
v2()  : non-empty-string
Returns a version 2 (DCE Security) UUID from a local domain, local identifier, host ID, clock sequence, and the current time
v3()  : non-empty-string
Returns a version 3 (name-based) UUID based on the MD5 hash of a namespace ID and a name
v4()  : non-empty-string
Returns a version 4 (random) UUID
v5()  : non-empty-string
Returns a version 5 (name-based) UUID based on the SHA-1 hash of a namespace ID and a name
v6()  : non-empty-string
Returns a version 6 (ordered-time) UUID from a host ID, sequence number, and the current time

Functions

v1()

Returns a version 1 (time-based) UUID from a host ID, sequence number, and the current time

v1([Hexadecimal|int|string|null $node = null ][, int $clockSeq = null ]) : non-empty-string
Parameters
$node : Hexadecimal|int|string|null = 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

Return values
non-empty-string

Version 1 UUID as a string

v2()

Returns a version 2 (DCE Security) UUID from a local domain, local identifier, host ID, clock sequence, and the current time

v2(int $localDomain[, Integer|null $localIdentifier = null ][, Hexadecimal|null $node = null ][, int|null $clockSeq = null ]) : non-empty-string
Parameters
$localDomain : int

The local domain to use when generating bytes, according to DCE Security

$localIdentifier : Integer|null = null

The local identifier for the given domain; this may be a UID or GID on POSIX systems, if the local domain is person or group, or it may be a site-defined identifier if the local domain is org

$node : Hexadecimal|null = null

A 48-bit number representing the hardware address

$clockSeq : int|null = 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

Return values
non-empty-string

Version 2 UUID as a string

v3()

Returns a version 3 (name-based) UUID based on the MD5 hash of a namespace ID and a name

v3(string|UuidInterface $ns, string $name) : non-empty-string
Parameters
$ns : string|UuidInterface

The namespace (must be a valid UUID)

$name : string
Tags
psalm-pure

note: changing the internal factory is an edge case not covered by purity invariants, but under constant factory setups, this method operates in functionally pure manners

Return values
non-empty-string

Version 3 UUID as a string

v4()

Returns a version 4 (random) UUID

v4() : non-empty-string
Return values
non-empty-string

Version 4 UUID as a string

v5()

Returns a version 5 (name-based) UUID based on the SHA-1 hash of a namespace ID and a name

v5(string|UuidInterface $ns, string $name) : non-empty-string
Parameters
$ns : string|UuidInterface

The namespace (must be a valid UUID)

$name : string
Tags
psalm-pure

note: changing the internal factory is an edge case not covered by purity invariants, but under constant factory setups, this method operates in functionally pure manners

Return values
non-empty-string

Version 5 UUID as a string

v6()

Returns a version 6 (ordered-time) UUID from a host ID, sequence number, and the current time

v6([Hexadecimal|null $node = null ][, int $clockSeq = null ]) : non-empty-string
Parameters
$node : Hexadecimal|null = null

A 48-bit number representing the hardware address

$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

Return values
non-empty-string

Version 6 UUID as a string

Search results