Hash::lolify()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Monolol\Lolifiers;
4
5
use Monolol\Lolifier;
6
7
class Hash implements Lolifier
8
{
9 1
    public function isHandling(array $record)
10
    {
11 1
        return true;
12
    }
13
14 1
    public function lolify(array $record)
15
    {
16 1
        $record['message'] = $this->hash($record['message']);
17
18 1
        return $record;
19
    }
20
21 1
    private function hash($string)
0 ignored issues
show
Coding Style Best Practice introduced by
Please use __construct() instead of a PHP4-style constructor that is named after the class.
Loading history...
22
    {
23 1
        $algorithm = $this->getRandomAlgorithm();
24
25 1
        return hash($algorithm, $string);
26
    }
27
28 1
    private function getRandomAlgorithm()
29
    {
30 1
        $algorithms = hash_algos();
31
32 1
        return $algorithms[array_rand($algorithms)];
33
    }
34
}
35
36