Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
66.67% |
2 / 3 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| LexemeCategoryField | |
66.67% |
2 / 3 |
|
0.00% |
0 / 1 |
2.15 | |
0.00% |
0 / 1 |
| getFieldData | |
66.67% |
2 / 3 |
|
0.00% |
0 / 1 |
2.15 | |||
| 1 | <?php |
| 2 | namespace Wikibase\Lexeme\Search\Elastic; |
| 3 | |
| 4 | use Wikibase\DataModel\Entity\EntityDocument; |
| 5 | use Wikibase\Lexeme\Domain\Model\Lexeme; |
| 6 | |
| 7 | /** |
| 8 | * Lexeme lexical category field - this contains Q-id of lexeme category. |
| 9 | */ |
| 10 | class LexemeCategoryField extends LexemeKeywordField { |
| 11 | public const NAME = 'lexical_category'; |
| 12 | |
| 13 | /** |
| 14 | * @param EntityDocument $entity |
| 15 | * |
| 16 | * @return mixed Get the value of the field to be indexed when a page/document |
| 17 | * is indexed. This might be an array with nested data, if the field |
| 18 | * is defined with nested type or an int or string for simple field types. |
| 19 | */ |
| 20 | public function getFieldData( EntityDocument $entity ) { |
| 21 | if ( !( $entity instanceof Lexeme ) ) { |
| 22 | return []; |
| 23 | } |
| 24 | /** |
| 25 | * @var Lexeme $entity |
| 26 | */ |
| 27 | return $entity->getLexicalCategory()->getSerialization(); |
| 28 | } |
| 29 | |
| 30 | } |