Total Complexity | 6 |
Total Lines | 30 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
7 | class Regex implements Validator { |
||
8 | private $pattern; |
||
9 | private $message; |
||
10 | |||
11 | /** |
||
12 | * @param string $pattern |
||
13 | * @param string $description |
||
14 | * @throws Exception |
||
15 | */ |
||
16 | 14 | public function __construct($pattern, $description = null) { |
|
17 | 14 | if (!$this->isValidRegexPattern($pattern)) |
|
18 | 2 | throw new Exception("Invalid Regex pattern: {$pattern}"); |
|
19 | 12 | $this->pattern = $pattern; |
|
20 | 12 | $this->message = $description; |
|
21 | 12 | } |
|
22 | |||
23 | 1 | public function getPattern() { |
|
24 | 1 | return $this->pattern; |
|
25 | } |
||
26 | |||
27 | 10 | public function validate($value) : bool { |
|
29 | } |
||
30 | |||
31 | 14 | protected function isValidRegexPattern($pattern) { |
|
33 | } |
||
34 | |||
35 | 6 | public function getDescription() { |
|
37 | } |
||
38 | } |