DTO for search results
This commit is contained in:
@@ -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,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user