Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 3 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
FauxSearchResultWithScore | |
0.00% |
0 / 3 |
|
0.00% |
0 / 2 |
6 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getScore | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace GrowthExperiments\NewcomerTasks; |
4 | |
5 | use FauxSearchResult; |
6 | use MediaWiki\Title\Title; |
7 | |
8 | /** |
9 | * A manually constructed search result, for use with FauxSearchResultSet. |
10 | * Unlike FauxSearchResult in core, it has a concept of CirrusSearch-like match scores. |
11 | * FIXME Since core does not have a concept of scores, and the SearchResult hierarchy is a mess, |
12 | * there is no nice way to express that this is a potential CirrusSearchResult replacement; |
13 | * code using it must be aware of it, or do duck typing. |
14 | */ |
15 | class FauxSearchResultWithScore extends FauxSearchResult { |
16 | |
17 | /** @var float Match score */ |
18 | protected $score; |
19 | |
20 | /** |
21 | * @param Title $title |
22 | * @param float $score |
23 | */ |
24 | public function __construct( Title $title, float $score = 0 ) { |
25 | parent::__construct( $title ); |
26 | $this->score = $score; |
27 | } |
28 | |
29 | /** |
30 | * Return match score for this result. |
31 | * @return float |
32 | */ |
33 | public function getScore() { |
34 | return $this->score; |
35 | } |
36 | |
37 | } |