Total Complexity | 3 |
Total Lines | 19 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
14 | class RegexMatch implements MatchInterface |
||
15 | { |
||
16 | /** @var string */ |
||
17 | private $value; |
||
18 | |||
19 | public function __construct(string $pattern, string $modifiers = '') |
||
20 | { |
||
21 | $regex = sprintf('/%s/%s', str_replace('/', '\/', $pattern), $modifiers); |
||
22 | |||
23 | if (false === preg_match($regex, '')) { |
||
24 | throw new InvalidRegexPatternException($pattern); |
||
25 | } |
||
26 | |||
27 | $this->value = $regex; |
||
28 | } |
||
29 | |||
30 | public function getValue(): string |
||
31 | { |
||
32 | return $this->value; |
||
33 | } |
||
35 |