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