PluginProbe
Media Cloud Sync / 1.4.2
Media Cloud Sync v1.4.2
1.4.2 1.4.1 1.4.0 1.3.12 1.3.11 1.3.10 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.2.0 1.2.10 1.2.11 1.2.12 1.2.13 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 All 36 releases
media-cloud-sync / includes / sdk / google / ramsey / uuid / src / functions.php

functions.php in Media Cloud Sync 1.4.2, at includes/sdk/google/ramsey/uuid/src/functions.php

128 lines 4.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * This file is part of the ramsey/uuid library
5 *
6 * For the full copyright and license information, please view the LICENSE
7 * file that was distributed with this source code.
8 *
9 * @copyright Copyright (c) Ben Ramsey <[email protected]>
10 * @license http://opensource.org/licenses/MIT MIT
11 * phpcs:disable Squiz.Functions.GlobalFunction
12 */
13 declare (strict_types=1);
14 namespace Dudlewebs\WPMCS\GCP\Ramsey\Uuid;
15
16 use DateTimeInterface;
17 use Dudlewebs\WPMCS\GCP\Ramsey\Uuid\Type\Hexadecimal;
18 use Dudlewebs\WPMCS\GCP\Ramsey\Uuid\Type\Integer as IntegerObject;
19 /**
20 * Returns a version 1 (Gregorian time) UUID from a host ID, sequence number, and the current time
21 *
22 * @param Hexadecimal | int | string | null $node A 48-bit number representing the hardware address; this number may be
23 * represented as an integer or a hexadecimal string
24 * @param int | null $clockSeq A 14-bit number used to help avoid duplicates that could arise when the clock is set
25 * backwards in time or if the node ID changes
26 *
27 * @return non-empty-string Version 1 UUID as a string
28 */
29 function v1($node = null, ?int $clockSeq = null) : string
30 {
31 return Uuid::uuid1($node, $clockSeq)->toString();
32 }
33 /**
34 * Returns a version 2 (DCE Security) UUID from a local domain, local identifier, host ID, clock sequence, and the current time
35 *
36 * @param int $localDomain The local domain to use when generating bytes, according to DCE Security
37 * @param IntegerObject | null $localIdentifier The local identifier for the given domain; this may be a UID or GID on
38 * POSIX systems, if the local domain is a person or group, or it may be a site-defined identifier if the local
39 * domain is org
40 * @param Hexadecimal | null $node A 48-bit number representing the hardware address
41 * @param int | null $clockSeq A 14-bit number used to help avoid duplicates that could arise when the clock is set
42 * backwards in time or if the node ID changes
43 *
44 * @return non-empty-string Version 2 UUID as a string
45 */
46 function v2(int $localDomain, ?IntegerObject $localIdentifier = null, ?Hexadecimal $node = null, ?int $clockSeq = null) : string
47 {
48 return Uuid::uuid2($localDomain, $localIdentifier, $node, $clockSeq)->toString();
49 }
50 /**
51 * Returns a version 3 (name-based) UUID based on the MD5 hash of a namespace ID and a name
52 *
53 * @param UuidInterface | string $ns The namespace (must be a valid UUID)
54 *
55 * @return non-empty-string Version 3 UUID as a string
56 *
57 * @pure
58 */
59 function v3($ns, string $name) : string
60 {
61 return Uuid::uuid3($ns, $name)->toString();
62 }
63 /**
64 * Returns a version 4 (random) UUID
65 *
66 * @return non-empty-string Version 4 UUID as a string
67 */
68 function v4() : string
69 {
70 return Uuid::uuid4()->toString();
71 }
72 /**
73 * Returns a version 5 (name-based) UUID based on the SHA-1 hash of a namespace ID and a name
74 *
75 * @param UuidInterface | string $ns The namespace (must be a valid UUID)
76 *
77 * @return non-empty-string Version 5 UUID as a string
78 *
79 * @pure
80 */
81 function v5($ns, string $name) : string
82 {
83 return Uuid::uuid5($ns, $name)->toString();
84 }
85 /**
86 * Returns a version 6 (reordered Gregorian time) UUID from a host ID, sequence number, and the current time
87 *
88 * @param Hexadecimal | null $node A 48-bit number representing the hardware address
89 * @param int | null $clockSeq A 14-bit number used to help avoid duplicates that could arise when the clock is set
90 * backwards in time or if the node ID changes
91 *
92 * @return non-empty-string Version 6 UUID as a string
93 */
94 function v6(?Hexadecimal $node = null, ?int $clockSeq = null) : string
95 {
96 return Uuid::uuid6($node, $clockSeq)->toString();
97 }
98 /**
99 * Returns a version 7 (Unix Epoch time) UUID
100 *
101 * @param DateTimeInterface|null $dateTime An optional date/time from which to create the version 7 UUID. If not
102 * provided, the UUID is generated using the current date/time.
103 *
104 * @return non-empty-string Version 7 UUID as a string
105 */
106 function v7(?DateTimeInterface $dateTime = null) : string
107 {
108 return Uuid::uuid7($dateTime)->toString();
109 }
110 /**
111 * Returns a version 8 (custom format) UUID
112 *
113 * The bytes provided may contain any value according to your application's needs. Be aware, however, that other
114 * applications may not understand the semantics of the value.
115 *
116 * @param string $bytes A 16-byte octet string. This is an open blob of data that you may fill with 128 bits of
117 * information. Be aware, however, bits 48 through 51 will be replaced with the UUID version field, and bits 64 and
118 * 65 will be replaced with the UUID variant. You MUST NOT rely on these bits for your application needs.
119 *
120 * @return non-empty-string Version 8 UUID as a string
121 *
122 * @pure
123 */
124 function v8(string $bytes) : string
125 {
126 return Uuid::uuid8($bytes)->toString();
127 }
128