MediaWiki master
FauxSearchResultSet.php
Go to the documentation of this file.
1<?php
2
3namespace MediaWiki\Search;
4
5use InvalidArgumentException;
7
14
19 private $totalHits;
20
25 public function __construct( array $results, $totalHits = null ) {
26 $totalHits = max( count( $results ), $totalHits );
27 $hasMoreResults = count( $results ) < $totalHits;
28 parent::__construct( false, $hasMoreResults );
29 $this->results = array_map( static function ( $result ) {
30 if ( $result instanceof SearchResult ) {
31 return $result;
32 } elseif ( $result instanceof Title ) {
33 return new FauxSearchResult( $result );
34 } else {
35 throw new InvalidArgumentException( '$results must contain Title or SearchResult' );
36 }
37 }, $results );
38 $this->totalHits = $totalHits;
39 }
40
42 public function getTotalHits() {
43 return $this->totalHits;
44 }
45
46}
47
49class_alias( FauxSearchResultSet::class, 'FauxSearchResultSet' );
A manually constructed search result set.
getTotalHits()
Some search modes return a total hit count for the query in the entire article database....
__construct(array $results, $totalHits=null)
A manually constructed search result, for use with FauxSearchResultSet.
SearchResult[] $results
Cache of results - serialization of the result iterator as an array.
An abstract base class representing a search engine result.
Represents a title within MediaWiki.
Definition Title.php:69
Definition of a mapping for the search index field.