3 class MockSearchResultSet
extends SearchResultSet
{
5 * @var SearchResultSet[][] Map from result type to list of results for
8 private $interwikiResults;
11 * @param SearchResult[]|callable[] $results
12 * @param ISearchResultSet[][]|callable[][] $interwikiResults Map from result type
13 * to list of results for that type.
15 public function __construct( array $results, array $interwikiResults = [] ) {
16 parent
::__construct( false, false );
17 $this->results
= $results;
18 $this->interwikiResults
= $interwikiResults;
21 public function numRows() {
22 return count( $this->results
);
25 public function hasInterwikiResults( $type = self
::SECONDARY_RESULTS
) {
26 return (bool)( $this->interwikiResults
[$type] ??
false );
29 public function extractResults() {
30 $results = parent
::extractResults();
32 foreach ( $results as &$result ) {
33 // Resolve deferred results; needed to work around T203279
34 if ( is_callable( $result ) ) {
42 public function getInterwikiResults( $type = self
::SECONDARY_RESULTS
) {
43 return $this->interwikiResults
[$type] ??
[];
46 public function getTotalHits() {
47 return $this->numRows();