WikibaseResourceNode::getDataValue()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace PPP\Wikidata;
4
5
use DataValues\DataValue;
6
use PPP\DataModel\ResourceNode;
7
use Wikibase\DataModel\Entity\EntityId;
8
use Wikibase\DataModel\Entity\PropertyId;
9
10
/**
11
 * Annotates intermediate representation with Wikibase
12
 *
13
 * @licence AGPLv3+
14
 * @author Thomas Pellissier Tanon
15
 */
16
class WikibaseResourceNode extends ResourceNode {
17
18
	/**
19
	 * @var DataValue
20
	 */
21
	private $dataValue;
22
23
	/**
24
	 * @var EntityId|null the subject from which the value is retrieved
25
	 */
26
	private $fromSubject;
27
28
	/**
29
	 * @var PropertyId|null the predicate from which the value is retrieved
30
	 */
31
	private $fromPredicate;
32
33
	/**
34
	 * @param string $value
35
	 * @param DataValue $dataValue
36
	 * @param EntityId $fromSubject
37
	 * @param PropertyId $fromPredicate
38
	 */
39 7
	public function __construct($value, DataValue $dataValue, EntityId $fromSubject = null, PropertyId $fromPredicate = null) {
40 7
		$this->dataValue = $dataValue;
41 7
		$this->fromSubject = $fromSubject;
42 7
		$this->fromPredicate = $fromPredicate;
43
44 7
		parent::__construct($value);
45 7
	}
46
47
	/**
48
	 * @return DataValue
49
	 */
50 1
	public function getDataValue() {
51 1
		return $this->dataValue;
52
	}
53
54
	/**
55
	 * @return EntityId|null
56
	 */
57 2
	public function getFromSubject() {
58 2
		return $this->fromSubject;
59
	}
60
61
	/**
62
	 * @return PropertyId|null
63
	 */
64 2
	public function getFromPredicate() {
65 2
		return $this->fromPredicate;
66
	}
67
68
	/**
69
	 * @see AbstractNode::equals
70
	 */
71 3
	public function equals($target) {
72 3
		return $target instanceof self &&
73 3
			$this->dataValue->equals($target->dataValue);
74
	}
75
76
	/**
77
	 * @see WikibaseResourceNode::equals
78
	 */
79 1
	public function getValueType() {
80 1
		return 'wikidata-datavalue';
81
	}
82
}
83