public function get_response_format()
{
if (!$this->response) {
throw new RestClientException("A response must exist before it can be decoded.");
}
// User-defined format.
if (!empty($this->options['format'])) {
return $this->options['format'];
}
// Extract format from response content-type header.
if (!empty($this->headers->content_type)) {
if (preg_match($this->options['format_regex'], $this->headers->content_type, $matches)) {
return $matches[2];
}
}
throw new RestClientException("Response format could not be determined.");
}