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 | 1 | 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 | 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 | public function generate(DocumentManager $dm, object $document) |
||
75 | |||
76 | /** |
||
77 | * Generates a v4 UUID |
||
78 | */ |
||
79 | public function generateV4() : string |
||
101 | |||
102 | /** |
||
103 | * Generates a v5 UUID |
||
104 | * |
||
105 | * @throws Exception When the provided namespace is invalid. |
||
106 | */ |
||
107 | public function generateV5(string $namespace, string $salt) : string |
||
144 | } |
||
145 |