private function parseResponse(Response $response, $path) { $statusCode = $response->getStatusCode(); if ($statusCode !== 200) { throw new UnexpectedValueException(sprintf('Expected status code 200 from "%s", got %d', $path, $statusCode)); } $contentType = $response->hasHeader('Content-Type') ? $response->getTokenizedHeader('content-type')->get(0) : ''; if ($contentType !== 'text/plain') { throw new UnexpectedValueException(sprintf('Expected content type "text/plain" from "%s", got "%s"', $path, $contentType)); } return $this->parseRequestFromResponse($response, $path); }