Generator   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 16
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A generateRandomString() 0 12 2
1
<?php
2
declare(strict_types=1);
3
4
namespace PTS\Tools;
5
6
use function strlen;
7
8
class Generator
9
{
10
11
    public function generateRandomString(
12
        int $length = 10,
13
        string $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!#%^*()-_[]{}<>=/|$'
14
    ): string {
15
        $randomStr = '';
16
        for ($i = 0; $i < $length; $i++) {
17
            $randomCharIndex = random_int(0, strlen($chars) - 1);
18
            $randomStr .= $chars[$randomCharIndex];
19
        }
20
21
        return $randomStr;
22
    }
23
}
24