ChangeOpFingerprint::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
namespace Wikibase\Repo\ChangeOp;
4
5
use Wikibase\DataModel\Entity\EntityDocument;
6
use Wikibase\Lib\Summary;
7
use Wikibase\Repo\Validators\TermValidatorFactory;
8
9
/**
10
 * Decorator on ChangeOps for collecting and distinguishing a collection
11
 * of ChangeOp instances on entity fingerprint parts.
12
 *
13
 * @license GPL-2.0-or-later
14
 */
15
class ChangeOpFingerprint extends ChangeOps {
16
17
	/** @var ChangeOps */
18
	private $innerChangeOps;
19
20
	/** @var TermValidatorFactory */
21
	private $termValidatorFactory;
22
23
	public function __construct( ChangeOps $innerChangeOps, TermValidatorFactory $termValidatorFactory ) {
24
		$this->innerChangeOps = $innerChangeOps;
25
		$this->termValidatorFactory = $termValidatorFactory;
26
	}
27
28
	public function add( $changeOps ) {
29
		$this->innerChangeOps->add( $changeOps );
30
	}
31
32
	public function getChangeOps() {
33
		return $this->innerChangeOps->getChangeOps();
34
	}
35
36
	public function validate( EntityDocument $entity ) {
37
		return $this->innerChangeOps->validate( $entity );
38
	}
39
40
	public function getActions() {
41
		return $this->innerChangeOps->getActions();
42
	}
43
44
	public function apply( EntityDocument $entity, Summary $summary = null ) {
45
		$result = $this->innerChangeOps->apply( $entity, $summary );
46
47
		'@phan-var ChangeOpsResult $result';
48
		return new ChangeOpFingerprintResult( $result, $this->termValidatorFactory );
0 ignored issues
show
Compatibility introduced by
$result of type object<Wikibase\Repo\ChangeOp\ChangeOpResult> is not a sub-type of object<Wikibase\Repo\ChangeOp\ChangeOpsResult>. It seems like you assume a concrete implementation of the interface Wikibase\Repo\ChangeOp\ChangeOpResult to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
49
	}
50
}
51