PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 6.3.0
Defender Security – Malware Scanner, Login Security & Firewall v6.3.0
6.3.0 6.2.3 6.2.4 6.2.0 6.2.1 6.2.2 6.1.0 5.3.1 5.4.0 5.4.1 5.5.0 5.5.1 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1 5.9.0 6.0.0 6.0.1 3.0.1 3.1.0 All 141 releases
defender-security / lib / packages / Ramsey / Uuid / functions.php

functions.php in Defender Security – Malware Scanner, Login Security & Firewall 6.3.0, at lib/packages/Ramsey/Uuid/functions.php

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