| Conditions | 3 |
| Paths | 3 |
| Total Lines | 13 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 3 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 31 | 35 | public static function generateRandomBitsInHex($bits) |
|
| 32 | { |
||
| 33 | 35 | if (null !== self::$fakeRandomBitsInHex) { |
|
| 34 | 5 | return self::$fakeRandomBitsInHex; |
|
| 35 | } |
||
| 36 | |||
| 37 | 34 | $length = $bits / 8; |
|
| 38 | 34 | if ($length < 1) { |
|
| 39 | 1 | throw new \Exception('Length must be greater than 0.'); |
|
| 40 | } |
||
| 41 | |||
| 42 | 33 | return bin2hex( |
|
| 43 | 33 | random_bytes($length) |
|
| 44 | 33 | ); |
|
| 47 |