1 | <?php |
||
18 | class SearchResult extends ParameterArrayConstructor implements JsonSerializable |
||
19 | { |
||
20 | /** |
||
21 | * URL of the search result |
||
22 | * @var string |
||
23 | */ |
||
24 | protected $url; |
||
25 | |||
26 | /** |
||
27 | * Description of result's relevance |
||
28 | * @var Relevance |
||
29 | */ |
||
30 | protected $relevance; |
||
31 | |||
32 | /** |
||
33 | * Human-readable title |
||
34 | * @var string |
||
35 | */ |
||
36 | protected $title; |
||
37 | |||
38 | /** |
||
39 | * Human-readable description |
||
40 | * |
||
41 | * Ideally 20-100 words, may be HTML-formatted (although links should be |
||
42 | * stripped out). |
||
43 | * @var string |
||
44 | */ |
||
45 | protected $description; |
||
46 | |||
47 | /** |
||
48 | * Simplified description of search domain source of the result |
||
49 | * @var SearchSource |
||
50 | */ |
||
51 | protected $source; |
||
52 | |||
53 | /** |
||
54 | * Construct a SearchResult |
||
55 | * |
||
56 | * Expects an associative parameter array: |
||
57 | * |
||
58 | * ``` |
||
59 | * [ |
||
60 | * 'url' => URL of the search result as a string, |
||
61 | * 'title' => Title of the search result as a string, |
||
62 | * 'relevance' => instance of `Relevance`, |
||
63 | * 'source' => instance of `SearchSource`, |
||
64 | * 'description' => Optional: search result descriptin as a string |
||
65 | * ] |
||
66 | * ``` |
||
67 | * |
||
68 | * @param array $params |
||
69 | */ |
||
70 | public function __construct($params) |
||
81 | |||
82 | /** |
||
83 | * Sort into order of descending relevance |
||
84 | * |
||
85 | * @param SearchResult[] $results |
||
86 | * @return void |
||
87 | */ |
||
88 | public static function sort(&$results) |
||
100 | |||
101 | public function getHash() |
||
105 | |||
106 | public function jsonSerialize() |
||
117 | } |
||
118 |