| 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 | 523 | public function __construct(Pattern ...$patterns) |
|
| 20 | { |
||
| 21 | 523 | $this->patterns = $patterns; |
|
| 22 | |||
| 23 | $patterns = array_map(function (Pattern $word) : string { |
||
| 24 | 523 | return $word->getPattern(); |
|
| 25 | 523 | }, $this->patterns); |
|
| 26 | |||
| 27 | 523 | $this->regex = '/^(?:' . implode('|', $patterns) . ')$/i'; |
|
| 28 | 523 | } |
|
| 29 | |||
| 30 | 505 | public function matches(string $word) : bool |
|
| 33 | } |
||
| 34 | } |
||
| 35 |