Total Complexity | 6 |
Total Lines | 44 |
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 |
|
27 | 17 | } |
|
28 | |||
29 | 2 | public function addResultWithErrorMessageWrapper(self $result, ErrorMessage $errorMessage): void |
|
30 | { |
||
31 | 2 | foreach ($result->errors as $error) { |
|
32 | 2 | $this->errors[] = new ErrorMessage( |
|
33 | 2 | $errorMessage->getMessage(), |
|
34 | 2 | array_merge(['error' => $error], $errorMessage->getParameters()) |
|
35 | ); |
||
36 | } |
||
37 | 2 | } |
|
38 | |||
39 | /** |
||
40 | * @param ErrorMessageFormatterInterface|null $formatter |
||
41 | * |
||
42 | * @return string[] |
||
43 | */ |
||
44 | 31 | public function getErrors(?ErrorMessageFormatterInterface $formatter = null): array |
|
51 | ); |
||
52 | } |
||
54 |