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 / 12
CrossProjectBlockScorerFactory
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 2
42
0.00% covered (danger)
0.00%
0 / 12
 load
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 3
 loadScorer
0.00% covered (danger)
0.00%
0 / 1
30
0.00% covered (danger)
0.00%
0 / 9
<?php
namespace CirrusSearch\Search;
use CirrusSearch\Profile\SearchProfileService;
use CirrusSearch\SearchConfig;
/**
 * Factory that reads cirrus config and builds a CrossProjectBlockScorer
 */
class CrossProjectBlockScorerFactory {
    /**
     * @param SearchConfig $searchConfig
     * @return CrossProjectBlockScorer
     */
    public static function load( SearchConfig $searchConfig ) {
        $profile = $searchConfig->getProfileService()
            ->loadProfile( SearchProfileService::CROSS_PROJECT_BLOCK_SCORER );
        return static::loadScorer( $profile['type'], $profile['settings'] ?? [] );
    }
    public static function loadScorer( $type, array $config ) {
        switch ( $type ) {
            case 'composite':
                return new CompositeCrossProjectBlockScorer( $config );
            case 'random':
                return new RandomCrossProjectBlockScorer( $config );
            case 'recall':
                return new RecallCrossProjectBlockScorer( $config );
            case 'static':
                return new StaticCrossProjectBlockScorer( $config );
            default:
                throw new \RuntimeException( 'Unknown CrossProjectBlockScorer type : ' . $type );
        }
    }
}