Exemple #1
0
 /**
  * {@inheritdoc}
  */
 public function getMatch(ServerRequestInterface $request) : Match
 {
     $matches = 0;
     foreach ($this->collection->getRoutes() as $route) {
         $match = $route->getResource()->isDynamic() ? $this->checkDynamicRoute($request, $route) : $this->checkStaticRoute($request, $route);
         if ($match instanceof Match) {
             if ($this->checkHttpMethod($request, $route)) {
                 return $match;
             }
             ++$matches;
         }
     }
     if ($matches) {
         throw new NotAllowedException("The given request's method is not allowed.");
     }
     throw new NotFoundException('No route was found to match the given request.');
 }
 /**
  * {@inheritdoc}
  */
 public function mergeCollection(RouteCollectionInterface $collection) : RouteCollectionInterface
 {
     $this->routes = array_merge($this->routes, $collection->getRoutes(true));
     return $this;
 }