Conditions | 2 |
Paths | 2 |
Total Lines | 12 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 6 |
CRAP Score | 2 |
Changes | 0 |
1 | <?php |
||
15 | 3 | public function generateRandomString( |
|
16 | int $length = 10, |
||
17 | string $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!#%^*()-_[]{}<>=/|$' |
||
18 | ): string { |
||
19 | 3 | $randomStr = ''; |
|
20 | 3 | for ($i = 0; $i < $length; $i++) { |
|
21 | 3 | $randomCharIndex = random_int(0, \strlen($chars) - 1); |
|
22 | 3 | $randomStr .= $chars[$randomCharIndex]; |
|
23 | } |
||
24 | |||
25 | 3 | return $randomStr; |
|
26 | } |
||
27 | } |
||
28 |