private function prepareDocuments(array $searchResponse, DocumentFactory $documentFactory) { $this->documents = []; if (isset($searchResponse['hits'])) { $hits = $searchResponse['hits']['hits']; foreach ($hits as $hit) { $this->documents[] = $documentFactory->create($hit); } $this->count = $searchResponse['hits']['total']; } }