/** * Call the method and return the results * @param type $version * @param Request $request * @throws Exception */ public function call($version, $request = null) { if (!isset($this->versions['all']) && !isset($this->versions[$version])) { throw new \RuntimeException('Invalid method call'); } if (!isset($this->versions[$version])) { $version = 'all'; } if (!empty($this->verifiers)) { foreach ($this->verifiers as $verifier) { if (!Api::verify($verifier, $request)) { throw new \InvalidArgumentException('Invalid API Call'); } } } $call = $this->versions[$version]['callback']; if (!is_callable($call)) { $func = $this->versions[$version]['method']; $controllerClassname = $call; $controller = new $controllerClassname(); return call_user_func_array(array($controller, $func), array($request)); } else { return call_user_func_array($call, array($request)); } }