Fake::generate()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 6
nc 2
nop 1
1
<?php
2
3
namespace OpCacheGUITest\Mocks\Security\Generator;
4
5
use OpCacheGUI\Security\Generator as SecurityGenerator;
6
7
class Fake implements SecurityGenerator
8
{
9
    /**
10
     * Generates a random string
11
     *
12
     * @param int $length The length of the random string to be generated
13
     */
14
    public function generate($length)
15
    {
16
        $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
17
        $randomString = '';
18
        for ($i = 0; $i < $length; $i++) {
19
            $randomString .= $characters[rand(0, strlen($characters) - 1)];
20
        }
21
22
        return $randomString;
23
    }
24
}
25