| Total Complexity | 5 |
| Total Lines | 32 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 2 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 7 | final class Result |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * @psalm-var list<int|string, string> |
||
| 11 | */ |
||
| 12 | private array $errors = []; |
||
| 13 | |||
| 14 | 158 | public function isValid(): bool |
|
| 17 | } |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @param string $message |
||
| 21 | * @param int|string|null $key |
||
| 22 | * @return void |
||
| 23 | */ |
||
| 24 | 128 | public function addError(string $message, $key = null): void |
|
| 25 | { |
||
| 26 | 128 | if ($key !== null && $key !== 0) { |
|
| 27 | 5 | $this->errors[$key] = $message; |
|
| 28 | } else { |
||
| 29 | 128 | $this->errors[] = $message; |
|
| 30 | } |
||
| 31 | 128 | } |
|
| 32 | |||
| 33 | /** |
||
| 34 | * @psalm-return list<int|string, string> |
||
| 35 | */ |
||
| 36 | 36 | public function getErrors(): array |
|
| 39 | } |
||
| 40 | } |
||
| 41 |