1 | <?php |
||
15 | abstract class AbstractTimeBasedUuidGenerator implements GeneratorInterface |
||
16 | { |
||
17 | /** |
||
18 | * Name of class to store explanation information |
||
19 | */ |
||
20 | const EXPLANATION_CLASS = Explanation::class; |
||
21 | |||
22 | /** |
||
23 | * Total UUID length |
||
24 | */ |
||
25 | const LENGTH = 36; |
||
26 | |||
27 | /** |
||
28 | * Length of second part |
||
29 | */ |
||
30 | const LENGTH_SECOND = 8; |
||
31 | |||
32 | /** |
||
33 | * Length of microsecond part |
||
34 | */ |
||
35 | const LENGTH_MICROSECOND = 4; |
||
36 | |||
37 | /** |
||
38 | * Length of group part |
||
39 | */ |
||
40 | const LENGTH_GROUP = 4; |
||
41 | |||
42 | /** |
||
43 | * Length of custom part |
||
44 | */ |
||
45 | const LENGTH_CUSTOM = 4; |
||
46 | |||
47 | /** |
||
48 | * Length of random part |
||
49 | */ |
||
50 | const LENGTH_RANDOM = 12; |
||
51 | |||
52 | /** |
||
53 | * How many chars check digit use, zero to disable it |
||
54 | * |
||
55 | * Longer can avoid duplicate but consume more length of random part. |
||
56 | */ |
||
57 | const LENGTH_CHECK_DIGIT = 0; |
||
58 | |||
59 | /** |
||
60 | * Separator chars between UUID parts |
||
61 | */ |
||
62 | const SEPARATOR = '-'; |
||
63 | |||
64 | |||
65 | /** |
||
66 | * Add check digit to an UUID |
||
67 | * |
||
68 | * Check digit will be add by replace chars from tail of UUID. |
||
69 | * |
||
70 | * Check digit should not include separator in common case. |
||
71 | * |
||
72 | * @param string $uuid |
||
73 | * @return string |
||
74 | */ |
||
75 | protected function addCheckDigit($uuid) |
||
84 | |||
85 | |||
86 | /** |
||
87 | * Compute check digit by given head part of UUID |
||
88 | * |
||
89 | * @param string $headPart |
||
90 | * @return string |
||
91 | */ |
||
92 | protected function computeCheckDigit($headPart) |
||
99 | |||
100 | |||
101 | /** |
||
102 | * {@inheritdoc} |
||
103 | */ |
||
104 | public function explain($uuid) |
||
150 | |||
151 | |||
152 | /** |
||
153 | * {@inheritdoc} |
||
154 | */ |
||
155 | public function generate($groupId = '1', $custom = '') |
||
170 | |||
171 | |||
172 | /** |
||
173 | * @param string $custom |
||
174 | * @return string |
||
175 | */ |
||
176 | protected function generateCustomPart($custom = '') |
||
184 | |||
185 | |||
186 | /** |
||
187 | * Generate custom part if not assigned from param |
||
188 | * |
||
189 | * Get something contains machine signature, used for custom part if needed |
||
190 | * |
||
191 | * Suggest generate from machine signature, got same result for one machine |
||
192 | * or environment, but random is also OK. |
||
193 | * |
||
194 | * Result length should >= custom part, will be used from left. |
||
195 | * |
||
196 | * @return string |
||
197 | */ |
||
198 | protected function generateCustomPartAuto() |
||
205 | |||
206 | |||
207 | /** |
||
208 | * @param string $groupId |
||
209 | * @return string |
||
210 | */ |
||
211 | protected function generateGroupPart($groupId) |
||
220 | |||
221 | |||
222 | /** |
||
223 | * @return string |
||
224 | */ |
||
225 | protected function generateRandomPart() |
||
231 | |||
232 | |||
233 | /** |
||
234 | * @return array |
||
235 | */ |
||
236 | protected function generateTimeParts() |
||
261 | |||
262 | |||
263 | /** |
||
264 | * {@inheritdoc} |
||
265 | * |
||
266 | * Without checkDigit, UUID can only verified by a few constraint like |
||
267 | * compare its length with definition. |
||
268 | * |
||
269 | * With checkDigit, UUID can be verified by re-compute check digits. |
||
270 | */ |
||
271 | public function verify($uuid) |
||
287 | } |
||
288 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.