Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 6 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
StaticCrossProjectBlockScorer | |
0.00% |
0 / 6 |
|
0.00% |
0 / 2 |
12 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
score | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | |
3 | namespace CirrusSearch\Search; |
4 | |
5 | /** |
6 | * Based on a static config, allows to give a fixed score to a particular |
7 | * wiki |
8 | */ |
9 | class StaticCrossProjectBlockScorer extends CrossProjectBlockScorer { |
10 | /** |
11 | * @var float[] Static weights |
12 | */ |
13 | private $staticScores; |
14 | |
15 | public function __construct( array $settings ) { |
16 | parent::__construct( $settings ); |
17 | $this->staticScores = $settings + [ '__default__' => 1 ]; |
18 | } |
19 | |
20 | /** |
21 | * @param string $prefix |
22 | * @param CirrusSearchResultSet $results |
23 | * @return float |
24 | */ |
25 | public function score( $prefix, CirrusSearchResultSet $results ) { |
26 | $staticScoreKey = '__default__'; |
27 | if ( isset( $this->staticScores[$prefix] ) ) { |
28 | $staticScoreKey = $prefix; |
29 | } |
30 | return $this->staticScores[$staticScoreKey]; |
31 | } |
32 | } |