From bdc2787ffd65556c1f4644e8408bc1f66a7342f2 Mon Sep 17 00:00:00 2001 From: Jay Fletcher Date: Sat, 6 Apr 2024 23:58:03 -0400 Subject: [PATCH] cleanup --- src/Application/Results.php | 5 +++-- src/Infrastructure/Elastic/Finder.php | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Application/Results.php b/src/Application/Results.php index 2a93531..e75bd04 100644 --- a/src/Application/Results.php +++ b/src/Application/Results.php @@ -5,14 +5,15 @@ namespace JeroenG\Explorer\Application; use Countable; +use Elastic\Elasticsearch\Response\Elasticsearch; class Results implements Countable { private array $rawResults; - public function __construct(array $rawResults) + public function __construct(array|Elasticsearch $rawResults) { - $this->rawResults = $rawResults; + $this->rawResults = $rawResults instanceof Elasticsearch ? $rawResults->asArray() : $rawResults; } public function hits(): array diff --git a/src/Infrastructure/Elastic/Finder.php b/src/Infrastructure/Elastic/Finder.php index 686bc1a..8957c96 100644 --- a/src/Infrastructure/Elastic/Finder.php +++ b/src/Infrastructure/Elastic/Finder.php @@ -25,6 +25,6 @@ public function find(): Results $rawResults = $this->client->search($query); - return new Results($rawResults->asArray()); + return new Results($rawResults); } }