ChangeOpsResult   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 2
dl 0
loc 43
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getChangeOpsResults() 0 3 1
A getEntityId() 0 3 1
A isEntityChanged() 0 9 3
A validate() 0 9 2
1
<?php
2
3
namespace Wikibase\Repo\ChangeOp;
4
5
use ValueValidators\Result;
6
use Wikibase\DataModel\Entity\EntityId;
7
8
/**
9
 * Class for collection of ChangeOp results
10
 */
11
class ChangeOpsResult implements ChangeOpResult {
12
13
	private $changeOpResults;
14
	private $entityId;
15
16
	/**
17
	 * @param EntityId|null $entityId
18
	 * @param ChangeOpResult[] $changeOpResults
19
	 */
20
	public function __construct( EntityId $entityId = null, array $changeOpResults = [] ) {
21
		$this->entityId = $entityId;
22
		$this->changeOpResults = $changeOpResults;
23
	}
24
25
	public function getChangeOpsResults() {
26
		return $this->changeOpResults;
27
	}
28
29
	public function getEntityId() {
30
		return $this->entityId;
31
	}
32
33
	public function isEntityChanged() {
34
		foreach ( $this->changeOpResults as $result ) {
35
			if ( $result->isEntityChanged() ) {
36
				return true;
37
			}
38
		}
39
40
		return false;
41
	}
42
43
	public function validate(): Result {
44
		$finalResult = Result::newSuccess();
45
46
		foreach ( $this->changeOpResults as $result ) {
47
			$finalResult = Result::merge( $finalResult, $result->validate() );
0 ignored issues
show
Documentation introduced by
$finalResult is of type object<ValueValidators\Result>, but the function expects a object<self>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Documentation introduced by
$result->validate() is of type object<ValueValidators\Result>, but the function expects a object<self>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
48
		}
49
50
		return $finalResult;
51
	}
52
53
}
54