getBody()->__toString(); case 'simple_xml': return self::convertToSimpleXml($response); case 'stream': return $response->getBody(); case 'psr7': return $response; default: throw new InvalidArgumentException('Format "%s" is not supported', $dataType); } } /** * @param ResponseInterface $response * * @return string */ public static function convertToArray(ResponseInterface $response) { return json_decode($response->getBody(), true); } /** * @param ResponseInterface $response * * @return \SimpleXMLElement * * @throws LinkedInTransferException */ public static function convertToSimpleXml(ResponseInterface $response) { $body = $response->getBody(); try { return new \SimpleXMLElement((string) $body ?: ''); } catch (\Exception $e) { throw new LinkedInTransferException('Unable to parse response body into XML.'); } } }