public function getData()
{
if ($this->_response == null) {
$response = $this->_responseString;
if ($response === false) {
$this->_error = true;
} else {
try {
if ($this->getJsonBigintConversion()) {
$response = JSON::parse($response, true, 512, JSON_BIGINT_AS_STRING);
} else {
$response = JSON::parse($response);
}
} catch (JSONParseException $e) {
// leave response as is if parse fails
}
}
if (empty($response)) {
$response = [];
}
if (is_string($response)) {
$response = ['message' => $response];
}
$this->_response = $response;
}
return $this->_response;
}
/** * Builds individual result objects. * * @param Response $response * * @return Result[] */ private function buildResults(Response $response) { $data = $response->getData(); $results = []; if (!isset($data['hits']['hits'])) { return $results; } foreach ($data['hits']['hits'] as $hit) { $results[] = new Result($hit); } return $results; }