| Total Complexity | 7 |
| Total Lines | 47 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 7 | final class Result |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * @var ErrorMessage[] |
||
| 11 | */ |
||
| 12 | private array $errors = []; |
||
| 13 | |||
| 14 | 140 | public function isValid(): bool |
|
| 17 | } |
||
| 18 | |||
| 19 | 122 | public function addError(ErrorMessage $error): void |
|
| 22 | 122 | } |
|
| 23 | |||
| 24 | 17 | public function addResult(self $result): void |
|
| 25 | { |
||
| 26 | 17 | $this->errors = array_merge($this->errors, $result->errors); |
|
| 27 | 17 | } |
|
| 28 | |||
| 29 | 2 | public function addResultWithWrapper(self $result, string $message='', array $params = []): void |
|
| 30 | { |
||
| 31 | 2 | foreach ($result->errors as $error) { |
|
| 32 | 2 | if (!empty($message)) { |
|
| 33 | 2 | $error = new ErrorMessage( |
|
| 34 | 2 | $message, |
|
| 35 | 2 | array_merge(['error' => $error], $params) |
|
| 36 | ); |
||
| 37 | } |
||
| 38 | 2 | $this->errors[] = $error; |
|
| 39 | } |
||
| 40 | 2 | } |
|
| 41 | |||
| 42 | /** |
||
| 43 | * @param ErrorMessageFormatterInterface|null $formatter |
||
| 44 | * |
||
| 45 | * @return string[] |
||
| 46 | */ |
||
| 47 | 31 | public function getErrors(?ErrorMessageFormatterInterface $formatter = null): array |
|
| 54 | ); |
||
| 55 | } |
||
| 56 | } |
||
| 57 |