MediaWiki REL1_41
FauxSearchResultSet.php
Go to the documentation of this file.
1<?php
2
4
11
16 private $totalHits;
17
22 public function __construct( array $results, $totalHits = null ) {
23 $totalHits = max( count( $results ), $totalHits );
24 $hasMoreResults = count( $results ) < $totalHits;
25 parent::__construct( false, $hasMoreResults );
26 $this->results = array_map( static function ( $result ) {
27 if ( $result instanceof SearchResult ) {
28 return $result;
29 } elseif ( $result instanceof Title ) {
30 return new FauxSearchResult( $result );
31 } else {
32 throw new InvalidArgumentException( '$results must contain Title or SearchResult' );
33 }
34 }, $results );
35 $this->totalHits = $totalHits;
36 }
37
39 public function getTotalHits() {
40 return $this->totalHits;
41 }
42
43}
A manually constructed search result set.
__construct(array $results, $totalHits=null)
getTotalHits()
Some search modes return a total hit count for the query in the entire article database....
A manually constructed search result, for use with FauxSearchResultSet.
Represents a title within MediaWiki.
Definition Title.php:76
SearchResult[] $results
Cache of results - serialization of the result iterator as an array.
NOTE: this class is being refactored into an abstract base class.