| Total Complexity | 8 |
| Total Lines | 65 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | class ValidationResult implements Result |
||
| 10 | { |
||
| 11 | use Guard; |
||
| 12 | |||
| 13 | use BelongsToField { |
||
| 14 | getField as private _getField; |
||
| 15 | } |
||
| 16 | |||
| 17 | /** @var string[] */ |
||
| 18 | private array $errors = []; |
||
| 19 | |||
| 20 | public static function ok(): self |
||
| 23 | } |
||
| 24 | |||
| 25 | public static function of(string $field, string ...$errors): self |
||
| 26 | { |
||
| 27 | return self::withErrors(...$errors)->field($field); |
||
| 28 | } |
||
| 29 | |||
| 30 | public static function withErrors(string ...$error): self |
||
| 35 | } |
||
| 36 | |||
| 37 | public function addError(string ...$errors): self |
||
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * @inheritDoc |
||
| 46 | */ |
||
| 47 | public function isOk(): bool |
||
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @inheritDoc |
||
| 54 | */ |
||
| 55 | public function getErrors(): array |
||
| 56 | { |
||
| 57 | return $this->errors; |
||
| 58 | } |
||
| 59 | |||
| 60 | /** |
||
| 61 | * @inheritDoc |
||
| 62 | */ |
||
| 63 | public function getField(): ?string |
||
| 64 | { |
||
| 65 | return $this->_getField(); |
||
| 66 | } |
||
| 67 | |||
| 68 | /** |
||
| 69 | * @throws ValidationExceptionInterface |
||
| 70 | */ |
||
| 71 | public function guard(?ValidationExceptionInterface $validationException = null): void |
||
| 74 | } |
||
| 75 | } |
||
| 76 |