| Total Complexity | 9 |
| Total Lines | 49 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 10 | class ErrorReporting implements Result |
||
| 11 | { |
||
| 12 | use GuardTrait; |
||
| 13 | |||
| 14 | /** @var Error[] */ |
||
| 15 | private array $errors = []; |
||
| 16 | |||
| 17 | final public function __construct(Error | Result ...$errors) |
||
| 23 | ); |
||
| 24 | } |
||
| 25 | } |
||
| 26 | |||
| 27 | public static function success(): self |
||
| 28 | { |
||
| 29 | return new self; |
||
| 30 | } |
||
| 31 | |||
| 32 | public function add(Error | Result ...$errors): self |
||
| 33 | { |
||
| 34 | return new self(...$this->errors, ...$errors); |
||
| 35 | } |
||
| 36 | |||
| 37 | public function addError(string $message, Rule $rule, ?string $field = null): self |
||
| 38 | { |
||
| 39 | return $this->add(new ErrorMessage($message, $rule, $field)); |
||
| 40 | } |
||
| 41 | |||
| 42 | /** @inheritDoc */ |
||
| 43 | public function isOk(): bool |
||
| 44 | { |
||
| 45 | return empty($this->errors); |
||
| 46 | } |
||
| 47 | |||
| 48 | /** @inheritDoc */ |
||
| 49 | public function getErrors(): array |
||
| 52 | } |
||
| 53 | |||
| 54 | /** @throws ValidationExceptionInterface */ |
||
| 55 | public function guard( |
||
| 59 | } |
||
| 60 | } |
||
| 61 |