Exemplo n.º 1
0
 /**
  * match a route against the current request.
  *
  * @param Request $request
  *
  * @return mixed
  */
 public function match(RequestInterface $request)
 {
     $rMethod = $request->getMethod();
     $requestPath = $request->path() == '/' ? '/' : '/' . $request->decodedPath();
     /*
      * check if any defined route matches the request path, if theres none, throw and exception
      */
     if (empty($this->currentRoute)) {
         throw new RouteNotFoundException(sprintf('the Route [%s] has not been defined', $requestPath));
     }
     /*
      * return the matched route for the dispatcher to consume
      */
     return $this->currentRoute[$rMethod][$requestPath];
 }