Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 12 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| CrossProjectBlockScorerFactory | |
0.00% |
0 / 12 |
|
0.00% |
0 / 2 |
56 | |
0.00% |
0 / 1 |
| load | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| loadScorer | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
42 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace CirrusSearch\Search; |
| 4 | |
| 5 | use CirrusSearch\Profile\SearchProfileService; |
| 6 | use CirrusSearch\SearchConfig; |
| 7 | |
| 8 | /** |
| 9 | * Factory that reads cirrus config and builds a CrossProjectBlockScorer |
| 10 | */ |
| 11 | class CrossProjectBlockScorerFactory { |
| 12 | /** |
| 13 | * @param SearchConfig $searchConfig |
| 14 | * @return CrossProjectBlockScorer |
| 15 | */ |
| 16 | public static function load( SearchConfig $searchConfig ) { |
| 17 | $profile = $searchConfig->getProfileService() |
| 18 | ->loadProfile( SearchProfileService::CROSS_PROJECT_BLOCK_SCORER ); |
| 19 | return static::loadScorer( $profile['type'], $profile['settings'] ?? [] ); |
| 20 | } |
| 21 | |
| 22 | public static function loadScorer( string $type, array $config ): CrossProjectBlockScorer { |
| 23 | switch ( $type ) { |
| 24 | case 'composite': |
| 25 | return new CompositeCrossProjectBlockScorer( $config ); |
| 26 | case 'random': |
| 27 | return new RandomCrossProjectBlockScorer( $config ); |
| 28 | case 'recall': |
| 29 | return new RecallCrossProjectBlockScorer( $config ); |
| 30 | case 'static': |
| 31 | return new StaticCrossProjectBlockScorer( $config ); |
| 32 | default: |
| 33 | throw new \RuntimeException( 'Unknown CrossProjectBlockScorer type : ' . $type ); |
| 34 | } |
| 35 | } |
| 36 | } |