| Conditions | 2 |
| Paths | 2 |
| Total Lines | 11 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 7 |
| CRAP Score | 2 |
| Changes | 0 | ||
| 1 | <?php |
||
| 35 | 2 | public static function random(int $length = 16): string |
|
| 36 | { |
||
| 37 | 2 | $string = ''; |
|
| 38 | 2 | while (($len = strlen($string)) < $length) { |
|
| 39 | 2 | $size = $length - $len; |
|
| 40 | 2 | $bytes = random_bytes($size); |
|
| 41 | 2 | $string .= substr(str_replace(['/', '+', '='], '', base64_encode($bytes)), 0, $size); |
|
| 42 | } |
||
| 43 | |||
| 44 | 2 | return $string; |
|
| 45 | } |
||
| 46 | |||
| 59 |