Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
27 / 27 |
|
100.00% |
7 / 7 |
CRAP | |
100.00% |
1 / 1 |
QualifierContextCursor | |
100.00% |
27 / 27 |
|
100.00% |
7 / 7 |
13 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
1 | |||
getType | n/a |
0 / 0 |
n/a |
0 / 0 |
1 | |||||
getEntityId | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getStatementPropertyId | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getStatementGuid | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getSnakPropertyId | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getSnakHash | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getMainArray | |
100.00% |
17 / 17 |
|
100.00% |
1 / 1 |
6 |
1 | <?php |
2 | |
3 | namespace WikibaseQuality\ConstraintReport\ConstraintCheck\Context; |
4 | |
5 | /** |
6 | * @license GPL-2.0-or-later |
7 | */ |
8 | class QualifierContextCursor extends ApiV2ContextCursor { |
9 | |
10 | /** |
11 | * @var string |
12 | */ |
13 | private $entityId; |
14 | |
15 | /** |
16 | * @var string |
17 | */ |
18 | private $statementPropertyId; |
19 | |
20 | /** |
21 | * @var string |
22 | */ |
23 | private $statementGuid; |
24 | |
25 | /** |
26 | * @var string |
27 | */ |
28 | private $snakHash; |
29 | |
30 | /** |
31 | * @var string |
32 | */ |
33 | private $snakPropertyId; |
34 | |
35 | /** |
36 | * @param string $entityId |
37 | * @param string $statementPropertyId |
38 | * @param string $statementGuid |
39 | * @param string $snakHash |
40 | * @param string $snakPropertyId |
41 | */ |
42 | public function __construct( |
43 | $entityId, |
44 | $statementPropertyId, |
45 | $statementGuid, |
46 | $snakHash, |
47 | $snakPropertyId |
48 | ) { |
49 | $this->entityId = $entityId; |
50 | $this->statementPropertyId = $statementPropertyId; |
51 | $this->statementGuid = $statementGuid; |
52 | $this->snakHash = $snakHash; |
53 | $this->snakPropertyId = $snakPropertyId; |
54 | } |
55 | |
56 | /** |
57 | * @codeCoverageIgnore This method is purely declarative. |
58 | */ |
59 | public function getType() { |
60 | return Context::TYPE_QUALIFIER; |
61 | } |
62 | |
63 | public function getEntityId() { |
64 | return $this->entityId; |
65 | } |
66 | |
67 | public function getStatementPropertyId() { |
68 | return $this->statementPropertyId; |
69 | } |
70 | |
71 | public function getStatementGuid() { |
72 | return $this->statementGuid; |
73 | } |
74 | |
75 | public function getSnakPropertyId() { |
76 | return $this->snakPropertyId; |
77 | } |
78 | |
79 | public function getSnakHash() { |
80 | return $this->snakHash; |
81 | } |
82 | |
83 | protected function &getMainArray( array &$container ) { |
84 | $statementArray = &$this->getStatementArray( $container ); |
85 | |
86 | if ( !array_key_exists( 'qualifiers', $statementArray ) ) { |
87 | $statementArray['qualifiers'] = []; |
88 | } |
89 | $qualifiersArray = &$statementArray['qualifiers']; |
90 | |
91 | $snakPropertyId = $this->getSnakPropertyId(); |
92 | if ( !array_key_exists( $snakPropertyId, $qualifiersArray ) ) { |
93 | $qualifiersArray[$snakPropertyId] = []; |
94 | } |
95 | $propertyArray = &$qualifiersArray[$snakPropertyId]; |
96 | |
97 | $snakHash = $this->getSnakHash(); |
98 | foreach ( $propertyArray as &$potentialQualifierArray ) { |
99 | if ( $potentialQualifierArray['hash'] === $snakHash ) { |
100 | $qualifierArray = &$potentialQualifierArray; |
101 | break; |
102 | } |
103 | } |
104 | if ( !isset( $qualifierArray ) ) { |
105 | $qualifierArray = [ 'hash' => $snakHash ]; |
106 | $propertyArray[] = &$qualifierArray; |
107 | } |
108 | |
109 | return $qualifierArray; |
110 | } |
111 | |
112 | } |