Total Complexity | 4 |
Total Lines | 20 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | #[Attribute] |
||
10 | class Pattern implements Rule |
||
11 | { |
||
12 | 1 | public function __construct(private string $pattern) {} |
|
13 | |||
14 | /** @return Type[] */ |
||
15 | 1 | public function applicableToTypes(): array |
|
16 | { |
||
17 | 1 | return [Type::string]; |
|
18 | } |
||
19 | |||
20 | /** @param string $value */ |
||
21 | 1 | public function isValid(mixed $value): bool |
|
22 | { |
||
23 | 1 | return preg_match($this->pattern, $value) === 1; |
|
24 | } |
||
25 | |||
26 | 1 | public function getMessage(): string |
|
29 | } |
||
30 | } |
||
31 |