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