ItemDiff::getType()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 2
ccs 0
cts 2
cp 0
crap 2
rs 10
1
<?php
2
3
namespace Wikibase\DataModel\Services\Diff;
4
5
use Diff\DiffOp\Diff\Diff;
6
use Diff\DiffOp\DiffOp;
7
8
/**
9
 * Represents a diff between two Item instances.
10
 *
11
 * @since 1.0
12
 *
13
 * @license GPL-2.0-or-later
14
 * @author Jeroen De Dauw < [email protected] >
15
 */
16
class ItemDiff extends EntityDiff {
17
18
	/**
19
	 * @param DiffOp[] $operations
20
	 */
21 29
	public function __construct( array $operations = [] ) {
22 29
		$this->fixSubstructureDiff( $operations, 'links' );
23
24 29
		parent::__construct( $operations );
25 29
	}
26
27
	/**
28
	 * Returns a Diff object with the sitelink differences.
29
	 *
30
	 * @return Diff
31
	 */
32 26
	public function getSiteLinkDiff() {
33 26
		return $this['links'] ?? new Diff( [], true );
34
	}
35
36
	/**
37
	 * @see EntityDiff::isEmpty
38
	 *
39
	 * @return bool
40
	 */
41 7
	public function isEmpty(): bool {
42 7
		return parent::isEmpty()
43 7
			&& $this->getSiteLinkDiff()->isEmpty();
44
	}
45
46
	/**
47
	 * @see DiffOp::getType
48
	 *
49
	 * @return string
50
	 */
51
	public function getType(): string {
52
		return 'diff/item';
53
	}
54
55
}
56