Example #1
0
 /**
  * Attempts to find a matching route for input $uri and $method
  * @param string $uri
  * @param string $method
  * @return IRoute
  */
 public function findMatch(\string $uri, \string $method)
 {
     foreach ($this->router->getRouteCollection() as $route) {
         if ($this->isRouteAMatch($route, $uri, $method)) {
             $route->setUserVariables($this->routeVariablesBuffer);
             return $route;
         }
     }
     return null;
 }
Example #2
0
 /**
  * @covers Zap\Routing\Router::setRouteCollection
  */
 public function testFetch()
 {
     $result = Router::get()->fetch('/some/uri', 'GET');
     $this->assertNull($result);
     // @todo extend test case, once method can return Zap\Http\Response
 }
Example #3
0
 /**
  * Registers route against router
  * @param Router|null $router
  * @return IRoute
  */
 public function register(Router $router = null) : IRoute
 {
     $router = is_null($router) ? Router::get() : $router;
     $router->addRoute($this);
     return $this;
 }