MatchByEntry::validate()   A
last analyzed

Complexity

Conditions 3
Paths 4

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 4
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\Interfaces;
7
8
9
/**
10
 * Class MatchByEntry
11
 * @package kalanis\kw_rules\Rules
12
 * Check if input matches rules by another entry
13
 * It's for things like checking phone number or post code with external source of country code
14
 */
15
class MatchByEntry extends ARule
16
{
17
    use TCheckEntry;
18
19
    /** @var Interfaces\IValidate */
20
    protected $againstValue;
21
22 2
    public function validate(Interfaces\IValidate $entry): void
23
    {
24 2
        foreach ($this->againstValue->getRules() as $rule) {
25 2
            $rule->validate($this->againstValue);
26
        }
27
28 1
        foreach ($entry->getRules() as $rule) {
29 1
            $rule->setAgainstValue($this->againstValue->getValue());
30 1
            $rule->validate($entry);
31
        }
32 1
    }
33
}
34