aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/ramsey/uuid/src/functions.php
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2021-01-13 09:50:53 +0000
committerMario <mario@mariovavti.com>2021-01-13 09:50:53 +0000
commit5eefdc6485b2f6082f6fe5dfd6f1731fae7e3a2a (patch)
tree7521f4800e393538d19c393c6f495ea2d41cbf5a /vendor/ramsey/uuid/src/functions.php
parent0bc4c7d1a0e4348018e533be600ad1c648fd97fb (diff)
parent4d2bcbc5837a7d99dc541595ca8087c335242af0 (diff)
downloadvolse-hubzilla-5eefdc6485b2f6082f6fe5dfd6f1731fae7e3a2a.tar.gz
volse-hubzilla-5eefdc6485b2f6082f6fe5dfd6f1731fae7e3a2a.tar.bz2
volse-hubzilla-5eefdc6485b2f6082f6fe5dfd6f1731fae7e3a2a.zip
Merge branch '5.2RC'5.2
Diffstat (limited to 'vendor/ramsey/uuid/src/functions.php')
-rw-r--r--vendor/ramsey/uuid/src/functions.php109
1 files changed, 74 insertions, 35 deletions
diff --git a/vendor/ramsey/uuid/src/functions.php b/vendor/ramsey/uuid/src/functions.php
index b5db34183..7b29ec4b1 100644
--- a/vendor/ramsey/uuid/src/functions.php
+++ b/vendor/ramsey/uuid/src/functions.php
@@ -8,71 +8,110 @@
*
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
* @license http://opensource.org/licenses/MIT MIT
+ * phpcs:disable Squiz.Functions.GlobalFunction
*/
+declare(strict_types=1);
+
namespace Ramsey\Uuid;
-use Exception;
-use InvalidArgumentException;
-use Ramsey\Uuid\Exception\InvalidUuidStringException;
-use Ramsey\Uuid\Exception\UnsatisfiedDependencyException;
+use Ramsey\Uuid\Type\Hexadecimal;
+use Ramsey\Uuid\Type\Integer as IntegerObject;
/**
- * Generate a version 1 UUID from a host ID, sequence number, and the current time.
+ * Returns a version 1 (time-based) UUID from a host ID, sequence number,
+ * and the current time
*
- * @param int|string|null $node A 48-bit number representing the hardware address
- * This number may be represented as an integer or a hexadecimal string.
- * @param int|null $clockSeq A 14-bit number used to help avoid duplicates that
+ * @param Hexadecimal|int|string|null $node A 48-bit number representing the
+ * hardware address; this number may be represented as an integer or a
+ * hexadecimal string
+ * @param int $clockSeq 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 string
- * @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
+ * changes
+ *
+ * @return string Version 1 UUID as a string
*/
-function v1($node = null, $clockSeq = null)
+function v1($node = null, ?int $clockSeq = null): string
{
return Uuid::uuid1($node, $clockSeq)->toString();
}
/**
- * 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).
+ * Returns a version 2 (DCE Security) UUID from a local domain, local
+ * identifier, host ID, clock sequence, and the current time
+ *
+ * @param int $localDomain The local domain to use when generating bytes,
+ * according to DCE Security
+ * @param IntegerObject|null $localIdentifier 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
+ * @param Hexadecimal|null $node A 48-bit number representing the hardware
+ * address
+ * @param int|null $clockSeq 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 string Version 2 UUID as a string
+ */
+function v2(
+ int $localDomain,
+ ?IntegerObject $localIdentifier = null,
+ ?Hexadecimal $node = null,
+ ?int $clockSeq = null
+): string {
+ return Uuid::uuid2($localDomain, $localIdentifier, $node, $clockSeq)->toString();
+}
+
+/**
+ * Returns a version 3 (name-based) UUID based on the MD5 hash of a
+ * namespace ID and a name
+ *
+ * @param string|UuidInterface $ns The namespace (must be a valid UUID)
*
- * @param string|UuidInterface $ns The UUID namespace in which to create the named UUID
- * @param string $name The name to create a UUID for
- * @return string
- * @throws InvalidUuidStringException
+ * @return string Version 3 UUID as a string
*/
-function v3($ns, $name)
+function v3($ns, string $name): string
{
return Uuid::uuid3($ns, $name)->toString();
}
/**
- * Generate a version 4 (random) UUID.
+ * Returns a version 4 (random) UUID
*
- * @return string
- * @throws UnsatisfiedDependencyException if `Moontoast\Math\BigNumber` is not present
- * @throws InvalidArgumentException
- * @throws Exception
+ * @return string Version 4 UUID as a string
*/
-function v4()
+function v4(): string
{
return Uuid::uuid4()->toString();
}
/**
- * 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).
+ * Returns a version 5 (name-based) UUID based on the SHA-1 hash of a
+ * namespace ID and a name
*
- * @param string|UuidInterface $ns The UUID namespace in which to create the named UUID
- * @param string $name The name to create a UUID for
- * @return string
- * @throws InvalidUuidStringException
+ * @param string|UuidInterface $ns The namespace (must be a valid UUID)
+ *
+ * @return string Version 5 UUID as a string
*/
-function v5($ns, $name)
+function v5($ns, string $name): string
{
return Uuid::uuid5($ns, $name)->toString();
}
+
+/**
+ * Returns a version 6 (ordered-time) UUID from a host ID, sequence number,
+ * and the current time
+ *
+ * @param Hexadecimal|null $node A 48-bit number representing the hardware
+ * address
+ * @param int $clockSeq 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 string Version 6 UUID as a string
+ */
+function v6(?Hexadecimal $node = null, ?int $clockSeq = null): string
+{
+ return Uuid::uuid6($node, $clockSeq)->toString();
+}