| Total Complexity | 6 |
| Total Lines | 38 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | abstract class AbstractRule implements Rule, BelongsToField, Stoppable |
||
| 10 | { |
||
| 11 | const MESSAGE = 'Contraint violation (%s)'; |
||
| 12 | |||
| 13 | use ValidateOrFailTrait, BelongsToFieldTrait, StoppableTrait; |
||
| 14 | |||
| 15 | public function __construct( |
||
| 16 | protected ?string $message = null, |
||
| 17 | int $stopOnFailure = StopSign::DONT_STOP |
||
| 18 | ) { |
||
| 19 | $this->stopOnFailure = $stopOnFailure; |
||
| 20 | } |
||
| 21 | |||
| 22 | public function message(): string |
||
| 25 | } |
||
| 26 | |||
| 27 | public function translatedMessage(): ?string |
||
| 28 | { |
||
| 29 | return Translator::translate(static::MESSAGE, $this->className()); |
||
| 30 | } |
||
| 31 | |||
| 32 | /** @inheritDoc */ |
||
| 33 | public function validate(mixed $input, array $context = []): Result |
||
| 39 | } |
||
| 40 | |||
| 41 | protected function className(): string |
||
| 44 | } |
||
| 45 | |||
| 46 | abstract public function isValid(mixed $input, array $context = []): bool; |
||
| 47 | } |
||
| 48 |