From 3ca696f71d008238cf555433b6b20590cf266fd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20P=2E?= Date: Mon, 15 Jun 2026 08:34:33 +0200 Subject: [PATCH] DTO for search results --- src/DTO/SearchResult.php | 2 ++ src/Service/SearchService.php | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/DTO/SearchResult.php b/src/DTO/SearchResult.php index 89310e9..a09a73b 100644 --- a/src/DTO/SearchResult.php +++ b/src/DTO/SearchResult.php @@ -17,6 +17,7 @@ final readonly class SearchResult implements JsonSerializable public array $notConserved, public array $findings, public array $underwater, + public int $count, ) {} public function jsonSerialize(): array @@ -26,6 +27,7 @@ final readonly class SearchResult implements JsonSerializable "notConserved" => $this->notConserved, "findings" => $this->findings, "underwater" => $this->underwater, + "count" => $this->count, ]; } } \ No newline at end of file diff --git a/src/Service/SearchService.php b/src/Service/SearchService.php index 8adb641..d1a4805 100644 --- a/src/Service/SearchService.php +++ b/src/Service/SearchService.php @@ -29,7 +29,7 @@ final class SearchService $filters = $this->normalizeFilters($rawFilters); // No results should be returned if no filter is valid - if (empty($filters)) return new SearchResult([], [], [], []); + if (empty($filters)) return new SearchResult([], [], [], [], 0); $sites = []; if (!(count($filters) === 1 && isset($filters['category']))) { @@ -49,6 +49,7 @@ final class SearchService notConserved: [], findings: $findings, underwater: [], + count: count($sites) + count($findings) ); return $result;