Total Complexity | 10 |
Total Lines | 41 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
13 | class Regex extends Parser |
||
14 | { |
||
15 | |||
16 | use CaseSensitiveTrait; |
||
17 | |||
18 | /** |
||
19 | * @var string|null |
||
20 | */ |
||
21 | private $pattern = null; |
||
22 | |||
23 | public function __construct($pattern) |
||
24 | { |
||
25 | if (empty($pattern)) { |
||
26 | throw new \InvalidArgumentException('Empty pattern'); |
||
27 | } |
||
28 | |||
29 | if (@preg_match($pattern, null) === false) { |
||
30 | throw new \InvalidArgumentException('Invalid pattern'); |
||
31 | } |
||
32 | |||
33 | $this->pattern = $pattern; |
||
34 | } |
||
35 | |||
36 | protected function parse(&$input, $offset, Context $context) |
||
49 | } |
||
50 | |||
51 | public function __toString() |
||
57 |