Conditions | 2 |
Paths | 2 |
Total Lines | 10 |
Code Lines | 4 |
Lines | 0 |
Ratio | 0 % |
Tests | 4 |
CRAP Score | 2.032 |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
39 | 5 | public static function randomBytes($length) |
|
40 | { |
||
41 | // Get $length cryptographically secure pseudo-random bytes |
||
42 | 5 | $rnd=\random_bytes($length); |
|
43 | |||
44 | 5 | if (strlen($rnd) !== $length) { |
|
45 | throw new Exception("random_bytes did not return the requested number of bytes"); |
||
46 | } |
||
47 | |||
48 | 5 | return $rnd; |
|
49 | } |
||
51 | } |