Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
5 / 5 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
ValueOnlyChecker | |
100.00% |
5 / 5 |
|
100.00% |
2 / 2 |
6 | |
100.00% |
1 / 1 |
getSupportedContextTypes | n/a |
0 / 0 |
n/a |
0 / 0 |
1 | |||||
getDefaultContextTypes | n/a |
0 / 0 |
n/a |
0 / 0 |
1 | |||||
getSupportedEntityTypes | n/a |
0 / 0 |
n/a |
0 / 0 |
1 | |||||
checkConstraint | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
2 | |||
checkConstraintParameters | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | namespace WikibaseQuality\ConstraintReport\ConstraintCheck\Checker; |
4 | |
5 | use WikibaseQuality\ConstraintReport\Constraint; |
6 | use WikibaseQuality\ConstraintReport\ConstraintCheck\ConstraintChecker; |
7 | use WikibaseQuality\ConstraintReport\ConstraintCheck\Context\Context; |
8 | use WikibaseQuality\ConstraintReport\ConstraintCheck\Message\ViolationMessage; |
9 | use WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult; |
10 | |
11 | /** |
12 | * @author Lucas Werkmeister |
13 | * @license GPL-2.0-or-later |
14 | */ |
15 | class ValueOnlyChecker implements ConstraintChecker { |
16 | |
17 | /** |
18 | * @codeCoverageIgnore This method is purely declarative. |
19 | */ |
20 | public function getSupportedContextTypes() { |
21 | return self::ALL_CONTEXT_TYPES_SUPPORTED; |
22 | } |
23 | |
24 | /** |
25 | * @codeCoverageIgnore This method is purely declarative. |
26 | */ |
27 | public function getDefaultContextTypes() { |
28 | return Context::ALL_CONTEXT_TYPES; |
29 | } |
30 | |
31 | /** @codeCoverageIgnore This method is purely declarative. */ |
32 | public function getSupportedEntityTypes() { |
33 | return self::ALL_ENTITY_TYPES_SUPPORTED; |
34 | } |
35 | |
36 | public function checkConstraint( Context $context, Constraint $constraint ) { |
37 | if ( $context->getType() === Context::TYPE_STATEMENT ) { |
38 | return new CheckResult( $context, $constraint, CheckResult::STATUS_COMPLIANCE ); |
39 | } else { |
40 | $message = new ViolationMessage( 'wbqc-violation-message-valueOnly' ); |
41 | return new CheckResult( $context, $constraint, CheckResult::STATUS_VIOLATION, $message ); |
42 | } |
43 | } |
44 | |
45 | public function checkConstraintParameters( Constraint $constraint ) { |
46 | // no parameters |
47 | return []; |
48 | } |
49 | |
50 | } |