Conditions | 4 |
Paths | 4 |
Total Lines | 15 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 7 |
CRAP Score | 4.1755 |
Changes | 0 |
1 | <?php |
||
24 | 4 | public function assert($data) |
|
25 | { |
||
26 | 4 | if (is_string($this->rule)) { |
|
27 | 1 | if (!$this->tester->parse($this->rule)->test($data)) { |
|
28 | 1 | throw new InvalidValueException([$this->rule]); |
|
29 | } |
||
30 | return; |
||
31 | 3 | } |
|
32 | |||
33 | $errorBag = new ErrorBag(); |
||
34 | $this->rule->define(new AssertRuleDefinition($this->tester, $errorBag, $data, $data)); |
||
35 | if (count($errorBag)) { |
||
36 | throw new InvalidValueException($errorBag->errors()); |
||
37 | 3 | } |
|
38 | 3 | } |
|
39 | 3 | ||
56 |