| Conditions | 4 |
| Paths | 4 |
| Total Lines | 16 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 4 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 16 | 2 | public function addResult(string $attribute, Result $result): self |
|
| 17 | { |
||
| 18 | 2 | $new = clone $this; |
|
| 19 | |||
| 20 | 2 | if (!isset($new->results[$attribute])) { |
|
| 21 | 2 | $new->results[$attribute] = $result; |
|
| 22 | 2 | return $new; |
|
| 23 | } |
||
| 24 | 2 | if ($result->isValid()) { |
|
| 25 | 1 | return $new; |
|
| 26 | } |
||
| 27 | 1 | foreach ($result->getErrors() as $error) { |
|
| 28 | 1 | $new->results[$attribute] = $new->results[$attribute]->addError($error); |
|
| 29 | } |
||
| 30 | |||
| 31 | 1 | return $new; |
|
| 32 | } |
||
| 48 |