Conditions | 1 |
Paths | 1 |
Total Lines | 27 |
Lines | 0 |
Ratio | 0 % |
Tests | 13 |
CRAP Score | 1 |
Changes | 0 |
1 | <?php |
||
12 | 2 | public function generate() |
|
13 | { |
||
14 | 2 | $time = explode(' ', microtime(false)); |
|
15 | 2 | $seconds = (int)$time[1]; |
|
16 | 2 | $milliseconds = (int)substr($time[0], 2, 4); |
|
17 | |||
18 | $params = [ |
||
19 | // 32 bits for "time_low" |
||
20 | 2 | $seconds >> 16, |
|
21 | 2 | $seconds & 0xffff, |
|
22 | // 16 bits for "time_mid" |
||
23 | 2 | $milliseconds, |
|
24 | // 16 bits for "time_hi_and_version", |
||
25 | // four most significant bits holds version number 4 |
||
26 | 2 | mt_rand(0, 0x0fff) | 0x4000, |
|
27 | // 16 bits, 8 bits for "clock_seq_hi_res", |
||
28 | // 8 bits for "clock_seq_low", |
||
29 | // two most significant bits hold one and zero for variant DCE1.1 |
||
30 | 2 | mt_rand(0, 0x3fff) | 0x8000, |
|
31 | // 48 bits for "node" |
||
32 | 2 | mt_rand(0, 0xffff), |
|
33 | 2 | mt_rand(0, 0xffff), |
|
34 | 2 | mt_rand(0, 0xffff) |
|
35 | ]; |
||
36 | |||
37 | 2 | return vsprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', $params); |
|
38 | } |
||
39 | } |
||
40 |