/** * Handle API response. * * @param stdClass $response * @return stdClass * @throws Everypay_Exception_ApiErrorException */ protected static function handleResponse($response) { $contentType = $response->getHeaderLine('Content-Type'); if (stripos($contentType, 'application/json') === false) { throw new Exception\CurlException('The returned response is not in json format'); } $response = json_decode($response->getBody()); if (isset($response->error->code)) { if (EveryPay::throwExceptions()) { throw new Everypay_Exception_ApiErrorException($response->error->message, $response->error->code); } } return $response; }