MatchAll   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 20
ccs 9
cts 9
cp 1
rs 10
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A validate() 0 16 4
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 MatchAll
12
 * @package kalanis\kw_rules\Rules
13
 * Check if input matches all subrules
14
 */
15
class MatchAll extends ARule
16
{
17
    use TCheckRules;
18
19 4
    public function validate(IValidate $entry): void
20
    {
21 4
        $last = null;
22 4
        foreach ($this->againstValue as $item) {
23
            /** @var ARule $item */
24
            try {
25 4
                $item->validate($entry);
26 3
            } catch (RuleException $ex) {
27
                // not good, continue for any other
28 3
                $ex->setPrev($last);
29 3
                $last = $ex;
30
            }
31
        }
32 4
        if (!empty($last)) {
33
            // it will die when something has been found
34 3
            throw new RuleException($this->errorText, 0, $last);
35
        }
36 1
    }
37
}
38