in src/Response/Elasticsearch.php [153:177]
public function asObject(): object
{
if (isset($this->asObject)) {
return $this->asObject;
}
$contentType = $this->response->getHeaderLine('Content-Type');
if (strpos($contentType, 'application/json') !== false ||
strpos($contentType, 'application/vnd.elasticsearch+json') !== false) {
$this->asObject = JsonSerializer::unserialize($this->asString(), ['type' => 'object']);
return $this->asObject;
}
if (strpos($contentType, 'application/x-ndjson') !== false ||
strpos($contentType, 'application/vnd.elasticsearch+x-ndjson') !== false) {
$this->asObject = NDJsonSerializer::unserialize($this->asString(), ['type' => 'object']);
return $this->asObject;
}
if (strpos($contentType, 'text/xml') !== false || strpos($contentType, 'application/xml') !== false) {
$this->asObject = XmlSerializer::unserialize($this->asString());
return $this->asObject;
}
throw new UnknownContentTypeException(sprintf(
"Cannot deserialize the reponse as object with Content-Type: %s",
$contentType
));
}