/** * Dispatch the request * * @param Route $route * * @throws NotFoundHttpException * @return mixed */ public function dispatch(Route $route) { $action = $route->action(); list($class, $method) = explode('@', $action['uses']); if (!method_exists($instance = $this->container->make($class), $method)) { throw new NotFoundHttpException(); } $parameters = $this->resolver->resolve(new ReflectionMethod($instance, $method), $route->parameters()); return $this->container->call([$instance, $method], $parameters); }
/** * @param Route $route * * @return bool */ public function isSatisfiedBy(Route $route) { $action = $route->action(); return is_callable($action['uses']); }
public function test_can_get_parameter() { $route = new Route(['GET'], '{id}', 'HomeController@index'); $route->bind(['id' => 1]); $this->assertEquals(1, $route->parameter('id')); }