Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
Random | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
2 | |
100.00% |
1 / 1 |
string | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
2 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace Projom\Util; |
6 | |
7 | class Random |
8 | { |
9 | public static function string(null|int $length = null, int $bytes = 10): string |
10 | { |
11 | $hex = bin2hex(random_bytes($bytes)); |
12 | if ($length === null) |
13 | return $hex; |
14 | |
15 | return substr($hex, 0, $length); |
16 | } |
17 | } |