Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 8 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
CrossProjectBlockScorer | |
0.00% |
0 / 8 |
|
0.00% |
0 / 2 |
20 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
score | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
reorder | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
12 |
1 | <?php |
2 | |
3 | namespace CirrusSearch\Search; |
4 | |
5 | /** |
6 | * Score an interwiki block |
7 | */ |
8 | abstract class CrossProjectBlockScorer { |
9 | public function __construct( array $settings ) { |
10 | } |
11 | |
12 | /** |
13 | * Compute a score for a given bloack of crossproject searchresults |
14 | * @param string $prefix |
15 | * @param CirrusSearchResultSet $results |
16 | * @return float the score for this block |
17 | */ |
18 | abstract public function score( $prefix, CirrusSearchResultSet $results ); |
19 | |
20 | /** |
21 | * Reorder crossproject blocks using the $scorer |
22 | * @param array $resultsets array of ResultSet or empty array if the search was disabled |
23 | * @return array ResultSet reordered |
24 | */ |
25 | public function reorder( array $resultsets ) { |
26 | $sortKeys = []; |
27 | foreach ( $resultsets as $pref => $results ) { |
28 | if ( $results instanceof CirrusSearchResultSet ) { |
29 | $sortKeys[] = $this->score( $pref, $results ); |
30 | } else { |
31 | $sortKeys[] = -1.0; |
32 | } |
33 | } |
34 | array_multisort( $sortKeys, SORT_DESC, $resultsets ); |
35 | return $resultsets; |
36 | } |
37 | } |