Total Complexity | 3 |
Total Lines | 21 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
11 | #[Attribute(Attribute::TARGET_PROPERTY)] |
||
12 | class Regex extends AbstractRule |
||
13 | { |
||
14 | const MESSAGE = 'Value does not match pattern: %s'; |
||
15 | |||
16 | public function __construct( |
||
17 | private string $pattern, |
||
18 | ?string $message = null, |
||
19 | int $stopOnFailure = StopSign::DONT_STOP |
||
20 | ) { |
||
21 | $message = $message ?? sprintf(self::MESSAGE, $this->pattern); |
||
22 | parent::__construct($message, $stopOnFailure); |
||
23 | } |
||
24 | |||
25 | public function isValid($input, array $context = []): bool |
||
32 | } |
||
33 | } |
||
35 |