DTO for search results

This commit is contained in:
2026-06-15 08:34:33 +02:00
parent 1c7c91af95
commit 3ca696f71d
2 changed files with 4 additions and 1 deletions

View File

@@ -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,
];
}
}

View File

@@ -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;