1 | <?php |
||
20 | final class Uuid |
||
21 | { |
||
22 | /** |
||
23 | * @var RamseyUuid|RhumsaaUuid; |
||
24 | */ |
||
25 | private $uuid; |
||
26 | |||
27 | private function __construct($uuid) |
||
31 | |||
32 | public static function fromString(string $uuid): self |
||
40 | |||
41 | /** |
||
42 | * Generate a version 1 UUID from a host ID, sequence number, and the current time. |
||
43 | * |
||
44 | * @param int|string $node a 48-bit number representing the hardware address |
||
45 | * This number may be represented as an integer or a hexadecimal string |
||
46 | * @param int $clockSeq a 14-bit number used to help avoid duplicates that |
||
47 | * could arise when the clock is set backwards in time or if the node ID |
||
48 | * changes |
||
49 | */ |
||
50 | public static function uuid1($node = null, int $clockSeq = null): self |
||
58 | |||
59 | /** |
||
60 | * Generate a version 3 UUID based on the MD5 hash of a namespace identifier |
||
61 | * (which is a UUID) and a name (which is a string). |
||
62 | * |
||
63 | * @param string $ns The UUID namespace in which to create the named UUID |
||
64 | * @param string $name The name to create a UUID for |
||
65 | */ |
||
66 | public static function uuid3(string $ns, string $name): self |
||
74 | |||
75 | /** |
||
76 | * Generate a version 4 (random) UUID. |
||
77 | */ |
||
78 | public static function uuid4(): self |
||
86 | |||
87 | /** |
||
88 | * Generate a version 5 UUID based on the SHA-1 hash of a namespace |
||
89 | * identifier (which is a UUID) and a name (which is a string). |
||
90 | * |
||
91 | * @param string $ns The UUID namespace in which to create the named UUID |
||
92 | * @param string $name The name to create a UUID for |
||
93 | */ |
||
94 | public static function uuid5(string $ns, string $name): self |
||
102 | |||
103 | public function __toString(): string |
||
107 | |||
108 | public function equals(Uuid $uuid): bool |
||
112 | } |
||
113 |