Conditions | 5 |
Paths | 6 |
Total Lines | 17 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 5 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
20 | 5 | public function validate(Interfaces\IValidate $entry): bool |
|
21 | { |
||
22 | 5 | $this->errors = []; |
|
23 | 5 | foreach ($entry->getRules() as $rule) { |
|
24 | try { |
||
25 | 5 | $rule->validate($entry); // for files need a whole object, so pack it all |
|
26 | 3 | } catch (RuleException $ex) { |
|
27 | 3 | if (empty($this->errors[$entry->getKey()])) { |
|
28 | 3 | $this->errors[$entry->getKey()] = []; |
|
29 | } |
||
30 | 3 | $this->errors[$entry->getKey()][] = $ex; |
|
31 | 3 | while ($ex = $ex->/** @scrutinizer ignore-call */getPrev()) { |
|
32 | 1 | $this->errors[$entry->getKey()][] = $ex; |
|
33 | } |
||
34 | } |
||
35 | } |
||
36 | 5 | return empty($this->errors); |
|
37 | } |
||
47 |