Conditions | 5 |
Paths | 4 |
Total Lines | 20 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
16 | public static function toUuid(string $blobString) |
||
17 | { |
||
18 | if (self::isValidUuid($blobString)) { |
||
19 | return $blobString; |
||
20 | } |
||
21 | |||
22 | if (strlen($blobString) === 16) { |
||
23 | $hex = bin2hex($blobString); |
||
24 | } elseif (strlen($blobString) === 32 && self::isValidHexUuid($blobString)) { |
||
25 | $hex = $blobString; |
||
26 | } else { |
||
27 | throw new InvalidArgumentException('Length of source data is should be 16 or 32 bytes.'); |
||
28 | } |
||
29 | |||
30 | return |
||
31 | substr($hex, 0, 8) . '-' . |
||
32 | substr($hex, 8, 4) . '-' . |
||
33 | substr($hex, 12, 4) . '-' . |
||
34 | substr($hex, 16, 4) . '-' . |
||
35 | substr($hex, 20) |
||
36 | ; |
||
58 |