1 | <?php |
||
23 | final class UuidGenerator extends AbstractIdGenerator |
||
24 | { |
||
25 | /** |
||
26 | * A unique environment value to salt each UUID with. |
||
27 | * |
||
28 | * @var string |
||
29 | */ |
||
30 | protected $salt = null; |
||
31 | |||
32 | /** |
||
33 | * Used to set the salt that will be applied to each id |
||
34 | */ |
||
35 | 2 | public function setSalt(string $salt) : void |
|
39 | |||
40 | /** |
||
41 | * Returns the current salt value |
||
42 | * |
||
43 | * @return string $salt The current salt |
||
44 | */ |
||
45 | 1 | public function getSalt() : string |
|
49 | |||
50 | /** |
||
51 | * Checks that a given string is a valid uuid. |
||
52 | */ |
||
53 | 2 | public function isValid(string $uuid) : bool |
|
58 | |||
59 | /** |
||
60 | * Generates a new UUID |
||
61 | * |
||
62 | * @param DocumentManager $dm Not used. |
||
63 | * @param object $document Not used. |
||
64 | * |
||
65 | * @return string UUID |
||
66 | * |
||
67 | * @throws Exception |
||
68 | */ |
||
69 | 2 | public function generate(DocumentManager $dm, object $document) |
|
74 | |||
75 | /** |
||
76 | * Generates a v4 UUID |
||
77 | */ |
||
78 | 4 | public function generateV4() : string |
|
100 | |||
101 | /** |
||
102 | * Generates a v5 UUID |
||
103 | * |
||
104 | * @throws Exception When the provided namespace is invalid. |
||
105 | */ |
||
106 | 2 | public function generateV5(string $namespace, string $salt) : string |
|
143 | } |
||
144 |