Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 4 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| MultiListWeightedTag | |
0.00% |
0 / 4 |
|
0.00% |
0 / 3 |
20 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| __toString | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
6 | |||
| getWeight | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace CirrusSearch\Extra\MultiList; |
| 4 | |
| 5 | /** |
| 6 | * Special {@link MultiListItem} representing a weighted tag. |
| 7 | * |
| 8 | * @see https://wikitech.wikimedia.org/wiki/Search/WeightedTags |
| 9 | */ |
| 10 | class MultiListWeightedTag extends MultiListItem { |
| 11 | |
| 12 | public const WEIGHT_DELIMITER = '|'; |
| 13 | |
| 14 | private ?int $weight; |
| 15 | |
| 16 | /** |
| 17 | * @param string $prefix Prefix |
| 18 | * @param string $name Name |
| 19 | * @param int|null $weight Weight |
| 20 | */ |
| 21 | public function __construct( string $prefix, string $name, ?int $weight = null ) { |
| 22 | parent::__construct( $prefix, $name ); |
| 23 | $this->weight = $weight; |
| 24 | } |
| 25 | |
| 26 | public function __toString(): string { |
| 27 | return parent::__toString() . ( $this->weight !== null ? self::WEIGHT_DELIMITER . $this->weight : '' ); |
| 28 | } |
| 29 | |
| 30 | public function getWeight(): ?int { |
| 31 | return $this->weight; |
| 32 | } |
| 33 | |
| 34 | } |