Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
12 / 12 |
|
100.00% |
4 / 4 |
CRAP | |
100.00% |
1 / 1 |
QualifierContext | |
100.00% |
12 / 12 |
|
100.00% |
4 / 4 |
4 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getType | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getSnakGroup | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getCursor | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | declare( strict_types = 1 ); |
4 | |
5 | namespace WikibaseQuality\ConstraintReport\ConstraintCheck\Context; |
6 | |
7 | use Wikibase\DataModel\Entity\StatementListProvidingEntity; |
8 | use Wikibase\DataModel\Snak\Snak; |
9 | use Wikibase\DataModel\Statement\Statement; |
10 | |
11 | /** |
12 | * A constraint check context for a qualifier of a statement. |
13 | * |
14 | * @license GPL-2.0-or-later |
15 | */ |
16 | class QualifierContext extends AbstractContext { |
17 | |
18 | private Statement $statement; |
19 | |
20 | public function __construct( |
21 | StatementListProvidingEntity $entity, |
22 | Statement $statement, |
23 | Snak $snak |
24 | ) { |
25 | parent::__construct( $entity, $snak ); |
26 | $this->statement = $statement; |
27 | } |
28 | |
29 | public function getType(): string { |
30 | return self::TYPE_QUALIFIER; |
31 | } |
32 | |
33 | public function getSnakGroup( string $groupingMode, array $separators = [] ): array { |
34 | $snaks = $this->statement->getQualifiers(); |
35 | return array_values( $snaks->getArrayCopy() ); |
36 | } |
37 | |
38 | public function getCursor(): ContextCursor { |
39 | return new QualifierContextCursor( |
40 | $this->entity->getId()->getSerialization(), |
41 | $this->statement->getPropertyId()->getSerialization(), |
42 | $this->getStatementGuid( $this->statement ), |
43 | $this->snak->getHash(), |
44 | $this->snak->getPropertyId()->getSerialization() |
45 | ); |
46 | } |
47 | |
48 | } |