TCheckEntry::checkValue()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 3
eloc 5
c 1
b 0
f 1
nc 3
nop 1
dl 0
loc 9
ccs 6
cts 6
cp 1
crap 3
rs 10
1
<?php
2
3
namespace kalanis\kw_rules\Rules;
4
5
6
use kalanis\kw_rules\Exceptions\RuleException;
7
use kalanis\kw_rules\Interfaces\IValidate;
8
9
10
/**
11
 * trait TCheckEntry
12
 * @package kalanis\kw_rules\Rules
13
 * Check original values as another entry
14
 */
15
trait TCheckEntry
16
{
17
    use TRule;
18
19
    /**
20
     * @param mixed|null $againstValue
21
     * @throws RuleException
22
     * @return IValidate
23
     */
24 4
    protected function checkValue($againstValue)
25
    {
26 4
        if (!is_object($againstValue)) {
27 1
            throw new RuleException('Input is not an object.');
28
        }
29 3
        if (! ($againstValue instanceof IValidate) ) {
30 1
            throw new RuleException(sprintf('Input %s is not instance of IValidate.', get_class($againstValue)));
31
        }
32 2
        return $againstValue;
33
    }
34
}
35