/** * @return string */ private function generateResponseFragment($indent = '') { $body = ''; $responseClass = $this->operationDefinition->getResponseClass(); $responseFactory = $this->operationDefinition->getResponseFactory(); $responseCallable = $this->operationDefinition->getResponseCallable(); if ($responseCallable) { throw new \Exception("This is not implemented yet."); } else { if (true) { //Hard-code this for now. $body .= <<<END {$indent}\$instance = \$this->api->instantiateResult(\$response, \$this); {$indent}return \$instance; END; } else { if ($responseFactory) { //Response is turned by $responseFactory into $responseClass $body .= <<<END {$indent}\$instance = \\{$responseClass}::createFromResponse(\$response, \$this); {$indent}return \$instance; END; } else { if ($responseClass) { //Response is turned into $responseClass by a static method on that class $body .= <<<END {$indent}\$instance = \\{$responseClass}::createFromResponse(\$response, \$this); {$indent}return \$instance; END; } else { //TODO - should this be like this or just return $response? //No hydrating of data done. $body .= $indent . 'return $response->getBody();'; } } } } return $body; }