| Total Complexity | 16 |
| Total Lines | 69 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 8 | class RegexRequestMatcher extends AbstractRequestMatcher |
||
| 9 | { |
||
| 10 | public function __construct(protected array $whitelist = [], protected array $blacklist = []) |
||
| 11 | { |
||
| 12 | |||
| 13 | } |
||
| 14 | |||
| 15 | public function matches(Request $request, ?int $requestType = HttpKernelInterface::MAIN_REQUEST): bool |
||
| 32 | } |
||
| 33 | |||
| 34 | protected function markRequestAsMatched(Request $request) |
||
| 35 | 8 | { |
|
| 36 | $request->attributes->set(self::ATTRIBUTE_MATCHED, true); |
||
| 37 | 8 | } |
|
| 38 | 4 | ||
| 39 | protected function matchPreviouslyMatchedRequest(Request $request): bool |
||
| 40 | { |
||
| 41 | 8 | return $request->attributes->getBoolean(self::ATTRIBUTE_MATCHED); |
|
| 42 | 2 | } |
|
| 43 | |||
| 44 | protected function matchRequestPathAgainstLists($requestPath): bool |
||
| 45 | 8 | { |
|
| 46 | 6 | if ($this->matchRequestPathAgainstBlacklist($requestPath)) { |
|
| 47 | return false; |
||
| 48 | } |
||
| 49 | 5 | ||
| 50 | if ($this->matchRequestPathAgainstWhitelist($requestPath)) { |
||
| 51 | 5 | return true; |
|
| 52 | } |
||
| 53 | |||
| 54 | return false; |
||
| 55 | } |
||
| 56 | |||
| 57 | 5 | protected function matchRequestPathAgainstBlacklist(string $requestPath): bool |
|
| 66 | 8 | } |
|
| 67 | |||
| 68 | 8 | protected function matchRequestPathAgainstWhitelist(string $requestPath): bool |
|
| 69 | { |
||
| 70 | foreach ($this->whitelist as $regex) { |
||
| 79 |