Total Complexity | 2 |
Total Lines | 22 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
11 | class Patterns |
||
12 | { |
||
13 | /** @var Pattern[] */ |
||
14 | private $patterns; |
||
15 | |||
16 | /** @var string */ |
||
17 | private $regex; |
||
18 | |||
19 | 761 | public function __construct(Pattern ...$patterns) |
|
20 | { |
||
21 | 761 | $this->patterns = $patterns; |
|
22 | |||
23 | $patterns = array_map(function (Pattern $pattern) : string { |
||
24 | 761 | return $pattern->getPattern(); |
|
25 | 761 | }, $this->patterns); |
|
26 | |||
27 | 761 | $this->regex = '/^(?:' . implode('|', $patterns) . ')$/i'; |
|
28 | 761 | } |
|
29 | |||
30 | 743 | public function matches(string $word) : bool |
|
33 | } |
||
34 | } |
||
35 |