| Total Complexity | 11 |
| Total Lines | 57 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 10 | final class CompositeMatcher implements PathMatcherInterface |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * @var PathMatcherInterface[] |
||
| 14 | */ |
||
| 15 | private array $matchers; |
||
| 16 | |||
| 17 | 14 | private function __construct( |
|
| 18 | private bool $matchAny, |
||
| 19 | PathMatcherInterface ...$matchers |
||
| 20 | ) { |
||
| 21 | 14 | $this->matchers = $matchers; |
|
| 22 | } |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Get an instance of composite matcher that gives a match if any of sub-matchers match. |
||
| 26 | * |
||
| 27 | * @param PathMatcherInterface ...$matchers Matchers to check. |
||
| 28 | */ |
||
| 29 | 7 | public static function any(PathMatcherInterface ...$matchers): self |
|
| 30 | { |
||
| 31 | 7 | return new self(true, ...$matchers); |
|
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * Get an instance of composite matcher that gives a match only if all of sub-matchers match. |
||
| 36 | * |
||
| 37 | * @param PathMatcherInterface ...$matchers Matchers to check. |
||
| 38 | */ |
||
| 39 | 7 | public static function all(PathMatcherInterface ...$matchers): self |
|
| 40 | { |
||
| 41 | 7 | return new self(false, ...$matchers); |
|
| 42 | } |
||
| 43 | |||
| 44 | 14 | public function match(string $path): ?bool |
|
| 67 | } |
||
| 68 | } |
||
| 69 |