Example #1
0
 /**
  * @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;
 }