OutRange::validate()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 3
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 5
ccs 4
cts 4
cp 1
crap 3
rs 10
1
<?php
2
3
namespace kalanis\kw_rules\Rules;
4
5
6
use kalanis\kw_rules\Interfaces\IValidate;
7
use kalanis\kw_rules\Exceptions\RuleException;
8
9
10
/**
11
 * Class OutRange
12
 * @package kalanis\kw_rules\Rules
13
 * Check if input is outside set range
14
 */
15
class OutRange extends ARule
16
{
17
    use TCheckRange;
18
19 5
    public function validate(IValidate $entry): void
20
    {
21 5
        $varToCheck = floatval($entry->getValue());
22 5
        if ($varToCheck > $this->againstValue[0] && $varToCheck < $this->againstValue[1]) {
23 1
            throw new RuleException($this->errorText);
24
        }
25 4
    }
26
}
27