data = json_decode($responseBody); $this->responseBody = $responseBody; $this->httpStatus = $httpStatus; $this->httpStatusMessage = $httpStatusMessage; // @extensionScannerIgnoreLine if (isset($this->data->response) && is_array($this->data->response->docs)) { $documents = array(); // @extensionScannerIgnoreLine foreach ($this->data->response->docs as $originalDocument) { $fields = get_object_vars($originalDocument); $document = new Document($fields); $documents[] = $document; } // @extensionScannerIgnoreLine $this->data->response->docs = $documents; } } /** * Magic get to expose the parsed data and to lazily load it * * @param string $key * @return mixed */ public function __get($key) { if (isset($this->data->$key)) { return $this->data->$key; } return null; } /** * Magic function for isset function on parsed data * * @param string $key * @return boolean */ public function __isset($key) { return isset($this->data->$key); } /** * @return mixed */ public function getParsedData() { return $this->data; } /** * @return string */ public function getRawResponse() { return $this->responseBody; } /** * @return int */ public function getHttpStatus(): int { return $this->httpStatus; } /** * @return string */ public function getHttpStatusMessage(): string { return $this->httpStatusMessage; } /** * Counts the elements of */ public function count() { return count(get_object_vars($this->data)); } }