Unsupported::generate()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
rs 9.4285
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
use OpCacheGUI\Security\Generator\UnsupportedAlgorithmException;
7
8
class Unsupported implements SecurityGenerator
9
{
10
    public function __construct()
11
    {
12
        throw new UnsupportedAlgorithmException('not supported');
13
    }
14
15
    /**
16
     * Generates a random string
17
     *
18
     * @param int $length The length of the random string to be generated
19
     */
20
    public function generate($length)
21
    {
22
        $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
23
        $randomString = '';
24
        for ($i = 0; $i < $length; $i++) {
25
            $randomString .= $characters[rand(0, strlen($characters) - 1)];
26
        }
27
28
        return $randomString;
29
    }
30
}
31