Example #1
0
 /**
  * @param Route $route
  *
  * @return mixed
  */
 public function dispatch(Route $route)
 {
     $handler = $route->handler();
     if (!is_callable($handler) && $this->resolver !== null) {
         $handler = call_user_func($this->resolver, $handler);
     }
     if (is_callable($handler)) {
         return call_user_func_array($handler, $route->attributes());
     }
     throw new \ErrorException("Target specified for '{$route->pattern()}' cannot be called");
 }
Example #2
0
 /**
  *
  */
 public function testParenthesisInPattern()
 {
     $response = new HTTPResponseStorage();
     $route = new Route('/{var}', 'get');
     $route->pattern('var', '(\\d)+');
     $route->handler(function ($var) {
         $this->assertEquals(3, $var);
     });
     $request = new HTTPRequestCustom('/3', 'get');
     $this->assertTrue($route->handle($request, $response, new Scope()));
 }