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 / 13
CompositeCrossProjectBlockScorer
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 2
20
0.00% covered (danger)
0.00%
0 / 13
 __construct
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 9
 score
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 4
<?php
namespace CirrusSearch\Search;
/**
 * Composite, weighted sum of a list of subscorers
 */
class CompositeCrossProjectBlockScorer extends CrossProjectBlockScorer {
    private $scorers = [];
    public function __construct( array $settings ) {
        parent::__construct( $settings );
        foreach ( $settings as $type => $subSettings ) {
            $weight = $subSettings['weight'] ?? 1;
            $scorerSettings = $subSettings['settings'] ?? [];
            $scorer = CrossProjectBlockScorerFactory::loadScorer( $type, $scorerSettings );
            $this->scorers[] = [
                'weight' => $weight,
                'scorer' => $scorer,
            ];
        }
    }
    /**
     * @param string $prefix
     * @param CirrusSearchResultSet $results
     * @return float
     */
    public function score( $prefix, CirrusSearchResultSet $results ) {
        $score = 0;
        foreach ( $this->scorers as $scorer ) {
            $score += $scorer['weight'] * $scorer['scorer']->score( $prefix, $results );
        }
        return $score;
    }
}