Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
5 / 5 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
EntityContextCursor | |
100.00% |
5 / 5 |
|
100.00% |
3 / 3 |
10 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
1 / 1 |
|
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 | n/a |
0 / 0 |
n/a |
0 / 0 |
1 | |||||
getStatementGuid | n/a |
0 / 0 |
n/a |
0 / 0 |
1 | |||||
getSnakPropertyId | n/a |
0 / 0 |
n/a |
0 / 0 |
1 | |||||
getSnakHash | n/a |
0 / 0 |
n/a |
0 / 0 |
1 | |||||
getMainArray | n/a |
0 / 0 |
n/a |
0 / 0 |
1 | |||||
storeCheckResultInArray | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace WikibaseQuality\ConstraintReport\ConstraintCheck\Context; |
4 | |
5 | use LogicException; |
6 | |
7 | /** |
8 | * A context cursor that is only associated with an entity, |
9 | * not with any statement or something else within it. |
10 | * It can only be used to partially populate a results container, |
11 | * not to actually store a full check result. |
12 | * This is used by {@link CheckingResultsSource} to ensure |
13 | * that even entities with no statements are present in the results container. |
14 | * |
15 | * @author Lucas Werkmeister |
16 | * @license GPL-2.0-or-later |
17 | * @phan-file-suppress PhanPluginNeverReturnMethod |
18 | */ |
19 | class EntityContextCursor extends ApiV2ContextCursor { |
20 | |
21 | /** |
22 | * @var string |
23 | */ |
24 | private $entityId; |
25 | |
26 | /** |
27 | * @param string $entityId |
28 | */ |
29 | public function __construct( |
30 | $entityId |
31 | ) { |
32 | $this->entityId = $entityId; |
33 | } |
34 | |
35 | /** |
36 | * @codeCoverageIgnore This method is not supported. |
37 | */ |
38 | public function getType() { |
39 | throw new LogicException( 'EntityContextCursor has no full associated context' ); |
40 | } |
41 | |
42 | public function getEntityId() { |
43 | return $this->entityId; |
44 | } |
45 | |
46 | /** |
47 | * @codeCoverageIgnore This method is not supported. |
48 | */ |
49 | public function getStatementPropertyId() { |
50 | throw new LogicException( 'EntityContextCursor has no full associated context' ); |
51 | } |
52 | |
53 | /** |
54 | * @codeCoverageIgnore This method is not supported. |
55 | */ |
56 | public function getStatementGuid() { |
57 | throw new LogicException( 'EntityContextCursor has no full associated context' ); |
58 | } |
59 | |
60 | /** |
61 | * @codeCoverageIgnore This method is not supported. |
62 | */ |
63 | public function getSnakPropertyId() { |
64 | throw new LogicException( 'EntityContextCursor has no full associated context' ); |
65 | } |
66 | |
67 | /** |
68 | * @codeCoverageIgnore This method is not supported. |
69 | */ |
70 | public function getSnakHash() { |
71 | throw new LogicException( 'EntityContextCursor has no full associated context' ); |
72 | } |
73 | |
74 | /** |
75 | * @codeCoverageIgnore This method is not supported. |
76 | */ |
77 | public function &getMainArray( array &$container ) { |
78 | throw new LogicException( 'EntityContextCursor cannot store check results' ); |
79 | } |
80 | |
81 | /** |
82 | * Populate the results container up to the 'claims' level. |
83 | * |
84 | * @param ?array $result must be null |
85 | * @param array[] &$container |
86 | */ |
87 | public function storeCheckResultInArray( ?array $result, array &$container ) { |
88 | if ( $result !== null ) { |
89 | throw new LogicException( 'EntityContextCursor cannot store check results' ); |
90 | } |
91 | |
92 | // this ensures that the claims array is present in the $container, |
93 | // populating it if necessary, even though we ignore the return value |
94 | $this->getClaimsArray( $container ); |
95 | } |
96 | |
97 | } |