MatchByEntry   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A validate() 0 9 3
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