Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 7
StaticCrossProjectBlockScorer
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 2
12
0.00% covered (danger)
0.00%
0 / 7
 __construct
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 3
 score
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 4
<?php
namespace CirrusSearch\Search;
/**
 * Based on a static config, allows to give a fixed score to a particular
 * wiki
 */
class StaticCrossProjectBlockScorer extends CrossProjectBlockScorer {
    /**
     * @var float[] Static weights
     */
    private $staticScores;
    public function __construct( array $settings ) {
        parent::__construct( $settings );
        $this->staticScores = $settings + [ '__default__' => 1 ];
    }
    /**
     * @param string $prefix
     * @param CirrusSearchResultSet $results
     * @return float
     */
    public function score( $prefix, CirrusSearchResultSet $results ) {
        $staticScoreKey = '__default__';
        if ( isset( $this->staticScores[$prefix] ) ) {
            $staticScoreKey = $prefix;
        }
        return $this->staticScores[$staticScoreKey];
    }
}