| Conditions | 2 |
| Paths | 2 |
| Total Lines | 11 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 7 |
| CRAP Score | 2 |
| Changes | 0 | ||
| 1 | <?php |
||
| 54 | 2 | public static function random(int $length = 16): string |
|
| 55 | { |
||
| 56 | 2 | $string = ''; |
|
| 57 | 2 | while (($len = strlen($string)) < $length) { |
|
| 58 | 2 | $size = $length - $len; |
|
| 59 | 2 | $bytes = random_bytes($size); |
|
| 60 | 2 | $string .= substr(str_replace(['/', '+', '='], '', base64_encode($bytes)), 0, $size); |
|
| 61 | } |
||
| 62 | |||
| 63 | 2 | return $string; |
|
| 64 | } |
||
| 65 | |||
| 78 |