/** * @return array */ public function getWildcards() : array { if (!isset($this->cache[__FUNCTION__])) { /** @var RouteCollection $collection */ $collection = $this->collection; $this->cache[__FUNCTION__] = parent::getWildcards() + $collection->getWildcards(); } return $this->cache[__FUNCTION__]; }
/** * @param BaseRouter|BaseRouter $router * @param BaseContext|Context $context * @param BaseRoute|Route $route * @return bool */ public function pass(BaseRouter $router, BaseContext $context, BaseRoute $route) : bool { //match secure if (null !== ($secure = $route->get('secure'))) { if ($secure !== $context->isSecure()) { return false; } } //match method if (!in_array($context->method(), $route->get('method', ['GET']))) { return false; } // match domain if (null !== ($domain = $route->get('domain'))) { $regex = $router->getRouteCollection()->getDomainCompiler()->getRegex($domain, $route->getWildcards()); return preg_match($regex, $context->domain()); } return true; }