PluginProbe
WCPOS – Point of Sale (POS) plugin for WooCommerce / 1.10.20
WCPOS – Point of Sale (POS) plugin for WooCommerce v1.10.20
1.10.20 1.10.19 1.10.18 1.10.17 1.10.16 1.10.15 1.10.13 1.10.14 1.10.12 1.10.11 1.10.10 1.10.9 1.10.8 untagged-3d9b7ccddc54df87c672 1.10.7 1.10.6 1.10.5 1.10.3 1.10.4 1.10.2 1.10.1 1.10.0 1.9.17 1.9.15 1.9.16 All 164 releases
woocommerce-pos / vendor / ramsey / uuid / src / functions.php

functions.php in WCPOS – Point of Sale (POS) plugin for WooCommerce 1.10.20, at vendor/ramsey/uuid/src/functions.php

124 lines 3.9 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 Ramsey\Uuid;
17
18 use Ramsey\Uuid\Type\Hexadecimal;
19 use Ramsey\Uuid\Type\Integer as IntegerObject;
20
21 /**
22 * Returns a version 1 (time-based) UUID from a host ID, sequence number,
23 * and the current time
24 *
25 * @param Hexadecimal|int|string|null $node A 48-bit number representing the
26 * hardware address; this number may be represented as an integer or a
27 * hexadecimal string
28 * @param int $clockSeq A 14-bit number used to help avoid duplicates that
29 * could arise when the clock is set backwards in time or if the node ID
30 * changes
31 *
32 * @return non-empty-string Version 1 UUID as a string
33 */
34 function v1($node = null, ?int $clockSeq = null): string
35 {
36 return Uuid::uuid1($node, $clockSeq)->toString();
37 }
38
39 /**
40 * Returns a version 2 (DCE Security) UUID from a local domain, local
41 * identifier, host ID, clock sequence, and the current time
42 *
43 * @param int $localDomain The local domain to use when generating bytes,
44 * according to DCE Security
45 * @param IntegerObject|null $localIdentifier The local identifier for the
46 * given domain; this may be a UID or GID on POSIX systems, if the local
47 * domain is person or group, or it may be a site-defined identifier
48 * if the local domain is org
49 * @param Hexadecimal|null $node A 48-bit number representing the hardware
50 * address
51 * @param int|null $clockSeq A 14-bit number used to help avoid duplicates
52 * that could arise when the clock is set backwards in time or if the
53 * node ID changes
54 *
55 * @return non-empty-string Version 2 UUID as a string
56 */
57 function v2(
58 int $localDomain,
59 ?IntegerObject $localIdentifier = null,
60 ?Hexadecimal $node = null,
61 ?int $clockSeq = null
62 ): string {
63 return Uuid::uuid2($localDomain, $localIdentifier, $node, $clockSeq)->toString();
64 }
65
66 /**
67 * Returns a version 3 (name-based) UUID based on the MD5 hash of a
68 * namespace ID and a name
69 *
70 * @param string|UuidInterface $ns The namespace (must be a valid UUID)
71 *
72 * @return non-empty-string Version 3 UUID as a string
73 *
74 * @psalm-pure note: changing the internal factory is an edge case not covered by purity invariants,
75 * but under constant factory setups, this method operates in functionally pure manners
76 */
77 function v3($ns, string $name): string
78 {
79 return Uuid::uuid3($ns, $name)->toString();
80 }
81
82 /**
83 * Returns a version 4 (random) UUID
84 *
85 * @return non-empty-string Version 4 UUID as a string
86 */
87 function v4(): string
88 {
89 return Uuid::uuid4()->toString();
90 }
91
92 /**
93 * Returns a version 5 (name-based) UUID based on the SHA-1 hash of a
94 * namespace ID and a name
95 *
96 * @param string|UuidInterface $ns The namespace (must be a valid UUID)
97 *
98 * @return non-empty-string Version 5 UUID as a string
99 *
100 * @psalm-pure note: changing the internal factory is an edge case not covered by purity invariants,
101 * but under constant factory setups, this method operates in functionally pure manners
102 */
103 function v5($ns, string $name): string
104 {
105 return Uuid::uuid5($ns, $name)->toString();
106 }
107
108 /**
109 * Returns a version 6 (ordered-time) UUID from a host ID, sequence number,
110 * and the current time
111 *
112 * @param Hexadecimal|null $node A 48-bit number representing the hardware
113 * address
114 * @param int $clockSeq A 14-bit number used to help avoid duplicates that
115 * could arise when the clock is set backwards in time or if the node ID
116 * changes
117 *
118 * @return non-empty-string Version 6 UUID as a string
119 */
120 function v6(?Hexadecimal $node = null, ?int $clockSeq = null): string
121 {
122 return Uuid::uuid6($node, $clockSeq)->toString();
123 }
124