| Total Complexity | 5 |
| Total Lines | 28 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 18 | */ |
||
| 19 | #[Attribute(Attribute::TARGET_PROPERTY)] |
||
| 20 | final class Required implements ParametrizedRuleInterface, PreValidatableRuleInterface |
||
| 21 | { |
||
| 22 | use HandlerClassNameTrait; |
||
| 23 | use PreValidatableTrait; |
||
| 24 | use RuleNameTrait; |
||
| 25 | |||
| 26 | 12 | public function __construct( |
|
| 27 | private string $message = 'Value cannot be blank.', |
||
| 28 | private bool $skipOnEmpty = false, |
||
| 29 | private bool $skipOnError = false, |
||
| 30 | private ?Closure $when = null, |
||
| 31 | ) { |
||
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * @return string |
||
| 36 | */ |
||
| 37 | 5 | public function getMessage(): string |
|
| 38 | { |
||
| 39 | 5 | return $this->message; |
|
| 40 | } |
||
| 41 | |||
| 42 | 2 | #[ArrayShape(['message' => 'string[]', 'skipOnEmpty' => 'bool', 'skipOnError' => 'bool'])] |
|
| 43 | public function getOptions(): array |
||
| 44 | { |
||
| 45 | return [ |
||
| 46 | 'message' => [ |
||
| 54 |