Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
NullResult
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 3
12
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
2
 getConstraint
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getConstraintId
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3declare( strict_types = 1 );
4
5namespace WikibaseQuality\ConstraintReport\ConstraintCheck\Result;
6
7use DomainException;
8use Wikibase\DataModel\Entity\NumericPropertyId;
9use WikibaseQuality\ConstraintReport\Constraint;
10use WikibaseQuality\ConstraintReport\ConstraintCheck\Context\ContextCursor;
11
12/**
13 * A blank CheckResult that only holds a context cursor, but no actual result.
14 * Used for contexts that should appear in the API output
15 * even if no constraints are defined for them.
16 *
17 * @author Lucas Werkmeister
18 * @license GPL-2.0-or-later
19 * @phan-file-suppress PhanPluginNeverReturnMethod
20 */
21class NullResult extends CheckResult {
22
23    /**
24     * The property ID that is used for the fake constraint passed to the superclass.
25     * Since the NumericPropertyId constructor prevents invalid property IDs like “P0”,
26     * we use the maximum permitted property ID and assume that it’s unlikely to actually exist.
27     */
28    private const NULL_PROPERTY_ID = 'P2147483647';
29
30    public function __construct( ContextCursor $contextCursor ) {
31        $constraint = new Constraint(
32            'null',
33            new NumericPropertyId( self::NULL_PROPERTY_ID ),
34            'none',
35            []
36        );
37        parent::__construct( $contextCursor, $constraint );
38    }
39
40    public function getConstraint(): Constraint {
41        throw new DomainException( 'NullResult holds no constraint' );
42    }
43
44    public function getConstraintId(): string {
45        throw new DomainException( 'NullResult holds no constraint' );
46    }
47
48}