MediaWiki
master
FauxSearchResultSet.php
Go to the documentation of this file.
1
<?php
2
8
class
FauxSearchResultSet
extends
SearchResultSet
{
9
14
private
$totalHits
;
15
20
public
function
__construct
( array
$results
,
$totalHits
=
null
) {
21
$totalHits
= max(
count
(
$results
),
$totalHits
);
22
$hasMoreResults
=
count
(
$results
) <
$totalHits
;
23
parent::__construct(
false
,
$hasMoreResults
);
24
$this->results = array_map(
function
( $result ) {
25
if
( $result instanceof
SearchResult
) {
26
return
$result;
27
} elseif ( $result instanceof
Title
) {
28
return
new
FauxSearchResult
( $result );
29
}
else
{
30
throw
new
InvalidArgumentException(
'$results must contain Title or SearchResult'
);
31
}
32
},
$results
);
33
$this->totalHits =
$totalHits
;
34
}
35
37
public
function
getTotalHits
() {
38
return
$this->totalHits
;
39
}
40
41
}
SearchResultSet\count
count()
Definition:
SearchResultSet.php:72
FauxSearchResultSet\__construct
__construct(array $results, $totalHits=null)
Definition:
FauxSearchResultSet.php:20
FauxSearchResult
A manually constructed search result, for use with FauxSearchResultSet.
Definition:
FauxSearchResult.php:8
FauxSearchResultSet\$totalHits
int null $totalHits
Definition:
FauxSearchResultSet.php:14
SearchResult
NOTE: this class is being refactored into an abstract base class.
Definition:
SearchResult.php:38
SearchResultSet
Definition:
SearchResultSet.php:27
Title
Represents a title within MediaWiki.
Definition:
Title.php:46
SearchResultSet\$results
SearchResult[] $results
Cache of results - serialization of the result iterator as an array.
Definition:
SearchResultSet.php:44
FauxSearchResultSet\getTotalHits
getTotalHits()
Some search modes return a total hit count for the query in the entire article database....
Definition:
FauxSearchResultSet.php:37
SearchResultSet\$hasMoreResults
bool $hasMoreResults
True when there are more pages of search results available.
Definition:
SearchResultSet.php:49
FauxSearchResultSet
A manually constructed search result set.
Definition:
FauxSearchResultSet.php:8
includes
search
FauxSearchResultSet.php
Generated on Sat Jan 23 2021 22:10:06 for MediaWiki by
1.8.19