wikimedia/mediawiki-extensions-CirrusSearch

View on GitHub
includes/BuildDocument/Completion/SuggestScoringMethodFactory.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

namespace CirrusSearch\BuildDocument\Completion;

use InvalidArgumentException;

/**
 * Create certain suggestion scoring method, by name.
 */
class SuggestScoringMethodFactory {
    /**
     * @param string $scoringMethod the name of the scoring method
     * @return SuggestScoringMethod
     * @throws InvalidArgumentException
     */
    public static function getScoringMethod( $scoringMethod ) {
        switch ( $scoringMethod ) {
            case 'incomingLinks':
                return new IncomingLinksScoringMethod();
            case 'quality':
                return new QualityScore();
            case 'popqual':
                return new PQScore();
        }
        throw new InvalidArgumentException( 'Unknown scoring method ' . $scoringMethod );
    }
}