| Conditions | 1 |
| Paths | 1 |
| Total Lines | 10 |
| Code Lines | 6 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 22 | public static function generate(): string |
||
| 23 | { |
||
| 24 | $string = random_bytes(16); |
||
| 25 | $string[6] = chr(ord($string[6]) & 0x0f | 0x40); // set version to 0100 |
||
| 26 | $string[8] = chr(ord($string[8]) & 0x3f | 0x80); // set bits 6-7 to 10 |
||
| 27 | |||
| 28 | $byteSlices = str_split(bin2hex($string), 4); |
||
| 29 | assert(!is_bool($byteSlices)); |
||
| 30 | |||
| 31 | return vsprintf('%s%s-%s-%s-%s-%s%s%s', $byteSlices); |
||
| 32 | } |
||
| 34 |