HashedBasicEquals   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 12
ccs 6
cts 6
cp 1
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A hash() 0 3 1
A validate() 0 4 2
1
<?php
2
3
namespace kalanis\kw_rules\Rules\Safe;
4
5
6
use kalanis\kw_rules\Interfaces\IValidate;
7
use kalanis\kw_rules\Exceptions\RuleException;
8
use kalanis\kw_rules\Rules\ARule;
9
10
11
/**
12
 * Class HashedBasicEquals
13
 * @package kalanis\kw_rules\Rules\Safe
14
 * Check if input hash is equal to hash of expected value
15
 */
16
class HashedBasicEquals extends ARule
17
{
18 2
    public function validate(IValidate $entry): void
19
    {
20 2
        if ($this->hash(strval($entry->getValue())) != $this->hash(strval($this->againstValue))) {
21 1
            throw new RuleException($this->errorText);
22
        }
23 1
    }
24
25 2
    protected function hash(string $input): string
26
    {
27 2
        return md5($input);
28
    }
29
}
30