Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
6 / 6 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
QualifierChecker | |
100.00% |
6 / 6 |
|
100.00% |
3 / 3 |
7 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 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 BP2014N1 |
13 | * @license GPL-2.0-or-later |
14 | */ |
15 | class QualifierChecker implements ConstraintChecker { |
16 | |
17 | public function __construct() { |
18 | } |
19 | |
20 | /** |
21 | * @codeCoverageIgnore This method is purely declarative. |
22 | */ |
23 | public function getSupportedContextTypes() { |
24 | return self::ALL_CONTEXT_TYPES_SUPPORTED; |
25 | } |
26 | |
27 | /** |
28 | * @codeCoverageIgnore This method is purely declarative. |
29 | */ |
30 | public function getDefaultContextTypes() { |
31 | return Context::ALL_CONTEXT_TYPES; |
32 | } |
33 | |
34 | /** @codeCoverageIgnore This method is purely declarative. */ |
35 | public function getSupportedEntityTypes() { |
36 | return self::ALL_ENTITY_TYPES_SUPPORTED; |
37 | } |
38 | |
39 | /** |
40 | * Checks 'Qualifier' constraint. |
41 | * |
42 | * @param Context $context |
43 | * @param Constraint $constraint |
44 | * |
45 | * @return CheckResult |
46 | */ |
47 | public function checkConstraint( Context $context, Constraint $constraint ) { |
48 | if ( $context->getType() === Context::TYPE_QUALIFIER ) { |
49 | return new CheckResult( $context, $constraint, CheckResult::STATUS_COMPLIANCE ); |
50 | } else { |
51 | $message = new ViolationMessage( 'wbqc-violation-message-qualifier' ); |
52 | return new CheckResult( $context, $constraint, CheckResult::STATUS_VIOLATION, $message ); |
53 | } |
54 | } |
55 | |
56 | public function checkConstraintParameters( Constraint $constraint ) { |
57 | // no parameters |
58 | return []; |
59 | } |
60 | |
61 | } |