Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| SuggestScoringMethodFactory | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
20 | |
0.00% |
0 / 1 |
| getScoringMethod | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
20 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace CirrusSearch\BuildDocument\Completion; |
| 4 | |
| 5 | use InvalidArgumentException; |
| 6 | |
| 7 | /** |
| 8 | * Create certain suggestion scoring method, by name. |
| 9 | */ |
| 10 | class SuggestScoringMethodFactory { |
| 11 | /** |
| 12 | * @param string $scoringMethod the name of the scoring method |
| 13 | * @return SuggestScoringMethod |
| 14 | * @throws InvalidArgumentException |
| 15 | */ |
| 16 | public static function getScoringMethod( $scoringMethod ) { |
| 17 | switch ( $scoringMethod ) { |
| 18 | case 'incomingLinks': |
| 19 | return new IncomingLinksScoringMethod(); |
| 20 | case 'quality': |
| 21 | return new QualityScore(); |
| 22 | case 'popqual': |
| 23 | return new PQScore(); |
| 24 | } |
| 25 | throw new InvalidArgumentException( 'Unknown scoring method ' . $scoringMethod ); |
| 26 | } |
| 27 | } |