RandomStringNoncer::hash()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 6
cts 6
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 0
crap 2
1
<?php
2
3
namespace Acquia\Rest;
4
5
/**
6
 * Returns a random string of ASCII characters.
7
 */
8
class RandomStringNoncer extends NoncerAbstract
9
{
10
    /**
11
     * {@inheritdoc}
12
     */
13 42
    protected function hash()
14
    {
15 42
        $string = '';
16 42
        for ($i = 0; $i < $this->length; $i++) {
17 42
            $string .= chr(mt_rand(32, 126));
18 42
        }
19 42
        return base64_encode($string);
20
    }
21
}
22