| Conditions | 1 |
| Paths | 1 |
| Total Lines | 9 |
| Code Lines | 6 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 7 |
| CRAP Score | 1 |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 12 | 1 | public static function v4() |
|
| 13 | { |
||
| 14 | 1 | $uuidStr = random_bytes(16); // 128 bits |
|
| 15 | 1 | $uuidStr[6] = chr(0x40 | (ord($uuidStr[6]) & 0x0f)); // Set the high nibble of the 7th byte to 4 |
|
| 16 | 1 | $uuidStr[8] = chr(0x80 | (ord($uuidStr[8]) & 0x3f)); // Set highest two bits of the 9th byte to 0b10 |
|
| 17 | |||
| 18 | 1 | return sprintf( |
|
| 19 | 1 | "%s%s-%s-%s-%s-%s%s%s", |
|
| 20 | 1 | ...str_split(bin2hex($uuidStr), 4) |
|
| 21 | ); |
||
| 25 |