Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
71.43% |
5 / 7 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
| DescriptionsProviderFieldDefinitions | |
71.43% |
5 / 7 |
|
50.00% |
1 / 2 |
3.21 | |
0.00% |
0 / 1 |
| __construct | |
50.00% |
2 / 4 |
|
0.00% |
0 / 1 |
2.50 | |||
| getFields | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Wikibase\Search\Elastic\Fields; |
| 4 | |
| 5 | use MediaWiki\Config\ConfigFactory; |
| 6 | use Wikibase\Repo\Search\Fields\FieldDefinitions; |
| 7 | |
| 8 | /** |
| 9 | * Definitions for any entity that has descriptions. |
| 10 | * |
| 11 | * @license GPL-2.0-or-later |
| 12 | * @author Stas Malyshev |
| 13 | */ |
| 14 | class DescriptionsProviderFieldDefinitions implements FieldDefinitions { |
| 15 | |
| 16 | /** |
| 17 | * @var array |
| 18 | */ |
| 19 | private $stemmingSettings; |
| 20 | |
| 21 | /** |
| 22 | * @param string[] $languageCodes |
| 23 | * @param ConfigFactory|null $configFactory |
| 24 | */ |
| 25 | public function __construct( |
| 26 | private readonly array $languageCodes, |
| 27 | ?ConfigFactory $configFactory = null, |
| 28 | ) { |
| 29 | if ( $configFactory === null ) { |
| 30 | $this->stemmingSettings = []; |
| 31 | } else { |
| 32 | $this->stemmingSettings = $configFactory->makeConfig( 'WikibaseCirrusSearch' ) |
| 33 | ->get( 'UseStemming' ); |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * @return WikibaseDescriptionsIndexField[] |
| 39 | */ |
| 40 | public function getFields() { |
| 41 | return [ |
| 42 | DescriptionsField::NAME => new DescriptionsField( $this->languageCodes, $this->stemmingSettings ), |
| 43 | ]; |
| 44 | } |
| 45 | |
| 46 | } |