Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
10 / 10 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| SearchResultSet | |
100.00% |
9 / 9 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| jsonSerialize | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | /** @license For full copyright and license information, please see the LICENSE.md file. */ |
| 6 | |
| 7 | namespace App\Core\Search\Domain\Model; |
| 8 | |
| 9 | defined('AMMONLY_APP') || exit('Direct script access is forbidden.'); |
| 10 | |
| 11 | use JsonSerializable; |
| 12 | |
| 13 | /** |
| 14 | * Search Result Set Aggregate. |
| 15 | * |
| 16 | * Encapsulates the entire search response across all queried modules with execution metrics. |
| 17 | * |
| 18 | * @package App\Core\Search\Domain\Model |
| 19 | */ |
| 20 | final readonly class SearchResultSet implements JsonSerializable |
| 21 | { |
| 22 | /** |
| 23 | * SearchResultSet constructor. |
| 24 | * |
| 25 | * @param string $query The original search term. |
| 26 | * @param string $mode The search execution mode used. |
| 27 | * @param list<SearchResultGroup> $groups Grouped module results. |
| 28 | * @param int $totalResults Total count across all modules. |
| 29 | * @param float $executionTimeMs Execution duration in milliseconds. |
| 30 | */ |
| 31 | public function __construct( |
| 32 | public string $query, |
| 33 | public string $mode, |
| 34 | public array $groups, |
| 35 | public int $totalResults, |
| 36 | public float $executionTimeMs |
| 37 | ) { |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * Serializes result set to array for JSON responses. |
| 42 | * |
| 43 | * @return array<string, mixed> Serialized data. |
| 44 | */ |
| 45 | public function jsonSerialize(): array |
| 46 | { |
| 47 | return [ |
| 48 | 'query' => $this->query, |
| 49 | 'mode' => $this->mode, |
| 50 | 'total_results' => $this->totalResults, |
| 51 | 'modules_count' => count($this->groups), |
| 52 | 'execution_time_ms' => $this->executionTimeMs, |
| 53 | 'groups' => $this->groups, |
| 54 | ]; |
| 55 | } |
| 56 | } |