1 | <?php |
||
20 | final class Uuid |
||
21 | { |
||
22 | /** |
||
23 | * @var RamseyUuid|RhumsaaUuid; |
||
24 | */ |
||
25 | private $uuid; |
||
26 | |||
27 | private function __construct($uuid) |
||
28 | { |
||
29 | $this->uuid = $uuid; |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | * @param string $uuid |
||
34 | * |
||
35 | * @return Uuid |
||
36 | */ |
||
37 | public static function fromString($uuid) |
||
45 | |||
46 | /** |
||
47 | * Generate a version 1 UUID from a host ID, sequence number, and the current time. |
||
48 | * |
||
49 | * @param int|string $node a 48-bit number representing the hardware address |
||
50 | * This number may be represented as an integer or a hexadecimal string |
||
51 | * @param int $clockSeq a 14-bit number used to help avoid duplicates that |
||
52 | * could arise when the clock is set backwards in time or if the node ID |
||
53 | * changes |
||
54 | * |
||
55 | * @return self |
||
56 | */ |
||
57 | public static function uuid1($node = null, $clockSeq = null) |
||
65 | |||
66 | /** |
||
67 | * Generate a version 3 UUID based on the MD5 hash of a namespace identifier |
||
68 | * (which is a UUID) and a name (which is a string). |
||
69 | * |
||
70 | * @param string $ns The UUID namespace in which to create the named UUID |
||
71 | * @param string $name The name to create a UUID for |
||
72 | * |
||
73 | * @return self |
||
74 | */ |
||
75 | public static function uuid3($ns, $name) |
||
83 | |||
84 | /** |
||
85 | * Generate a version 4 (random) UUID. |
||
86 | * |
||
87 | * @return self |
||
88 | */ |
||
89 | public static function uuid4() |
||
97 | |||
98 | /** |
||
99 | * Generate a version 5 UUID based on the SHA-1 hash of a namespace |
||
100 | * identifier (which is a UUID) and a name (which is a string). |
||
101 | * |
||
102 | * @param string $ns The UUID namespace in which to create the named UUID |
||
103 | * @param string $name The name to create a UUID for |
||
104 | * |
||
105 | * @return self |
||
106 | */ |
||
107 | public static function uuid5($ns, $name) |
||
115 | |||
116 | public function __toString() |
||
120 | |||
121 | public function equals(Uuid $uuid) |
||
125 | } |
||
126 |