| Total Complexity | 6 |
| Total Lines | 50 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 18 | */ |
||
| 19 | #[Attribute(Attribute::TARGET_PROPERTY)] |
||
| 20 | final class Json implements ParametrizedRuleInterface, PreValidatableRuleInterface |
||
| 21 | { |
||
| 22 | use HandlerClassNameTrait; |
||
| 23 | use PreValidatableTrait; |
||
| 24 | use RuleNameTrait; |
||
| 25 | |||
| 26 | public function __construct( |
||
| 27 | private string $message = 'The value is not JSON.', |
||
| 28 | private bool $skipOnEmpty = false, |
||
| 29 | private bool $skipOnError = false, |
||
| 30 | private ?Closure $when = null, |
||
| 31 | ) { |
||
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * @return string |
||
| 36 | */ |
||
| 37 | 6 | public function getMessage(): string |
|
| 38 | { |
||
| 39 | 6 | return $this->message; |
|
| 40 | } |
||
| 41 | |||
| 42 | 1 | #[ArrayShape(['message' => 'string[]', 'skipOnEmpty' => 'bool', 'skipOnError' => 'bool'])] |
|
| 43 | public function getOptions(): array |
||
| 44 | { |
||
| 45 | return [ |
||
| 46 | 'message' => [ |
||
| 47 | 1 | 'message' => $this->message, |
|
| 48 | ], |
||
| 49 | 1 | 'skipOnEmpty' => $this->skipOnEmpty, |
|
| 50 | 1 | 'skipOnError' => $this->skipOnError, |
|
| 51 | ]; |
||
| 52 | } |
||
| 53 | } |
||
| 54 |