| Total Complexity | 4 |
| Total Lines | 27 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 14 | abstract class AbstractValidation implements Validation |
||
| 15 | { |
||
| 16 | use GuardForValidation, |
||
| 17 | MaybeBelongsToField; |
||
| 18 | |||
| 19 | protected string $message; |
||
| 20 | |||
| 21 | public function __construct(?string $message = null) |
||
| 24 | } |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @inheritDoc |
||
| 28 | */ |
||
| 29 | public function validate(mixed $input, array $context = []): Result |
||
| 30 | { |
||
| 31 | $result = $this->newEmptyValidationResult(); |
||
| 32 | return $this->evaluate($input, $context) ? $result: $result->error($this->message); |
||
| 33 | } |
||
| 34 | |||
| 35 | public function isValid($input, array $context = []): bool |
||
| 38 | } |
||
| 39 | |||
| 40 | abstract protected function evaluate($input, array $context = []): bool; |
||
| 41 | } |
||
| 42 |