public function call(Context $context) { $route = $context->getProp(RoutingApp::CURRENT_ROUTE); $instance = $route->getResourceInstance(); $methodName = $route->getResourceMethod(); $routeParams = $route->getParams(); $getParams = $_GET; $rMethod = $this->getReflectionMethod($instance, $methodName); $methodArgs = $this->getMethodArgs($rMethod, $context, $routeParams, $getParams); $to = $rMethod->invokeArgs($instance, $methodArgs); $body; if ($to instanceof ResponseBody) { $body = $to; } else { $body = new UnmarshalledBody($to); } $context->getResponse()->setBody($body); }