コード例 #1
0
ファイル: Matcher.php プロジェクト: php-zap/zap-routing
 /**
  * Returns true if Route matches input $uri and $method, false otherwise
  * @param IRoute $route
  * @param string $uri
  * @param string $method
  * @return bool
  */
 private function isRouteAMatch(IRoute $route, \string $uri, \string $method) : \bool
 {
     if ($route->getMethod() == $method) {
         if ($route->getUri() == $uri) {
             return true;
         }
         $routeUriArray = $this->sliceUri($route->getUri());
         $inputUriArray = $this->sliceUri($uri);
         return $this->compareSegmentLists($routeUriArray, $inputUriArray);
     }
     return false;
 }
コード例 #2
0
 /**
  * Initializes controller and checks if target method is callable
  * @throws InvalidRouteException
  */
 private function initController()
 {
     $fullClassName = $this->route->getControllerClass();
     $methodName = $this->route->getControllerMethod();
     if (!class_exists($fullClassName)) {
         throw new InvalidRouteException('Controller class does not exist: ' . $fullClassName);
     }
     $this->controller = new $fullClassName();
     if (!method_exists($this->controller, $methodName)) {
         throw new InvalidRouteException('Controller method does not exist: ' . $methodName);
     }
 }
コード例 #3
0
 /**
  * Removes a route from collection
  * @param IRoute|string $route
  * @return RouteCollection
  */
 public function remove($route) : RouteCollection
 {
     $key = $route instanceof Route ? $route->getUri() : $route;
     $this->offsetUnset($key);
     return $this;
 }