UnknownResourceNode::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
c 0
b 0
f 0
ccs 4
cts 4
cp 1
rs 9.4285
nc 1
cc 1
eloc 3
nop 2
crap 1
1
<?php
2
3
namespace PPP\DataModel;
4
5
/**
6
 * A JSON-LD resource node.
7
 *
8
 * @licence MIT
9
 * @author Thomas Pellissier Tanon
10
 */
11
class UnknownResourceNode extends ResourceNode {
12
13
	/**
14
	 * @var array
15
	 */
16
	private $properties;
17
18
	/**
19
	 * @param string $value
20
	 * @param array $additionalProperties
21
	 */
22 5
	public function __construct($value, array $additionalProperties) {
23 5
		$this->properties = $additionalProperties;
24
25 5
		parent::__construct($value);
26 5
	}
27
28 1
	public function getProperties() {
29 1
		return $this->properties;
30
	}
31
32
	/**
33
	 * @return string
34
	 */
35 2
	public function getValueType() {
36 2
		return array_key_exists( 'value-type', $this->properties )
37 2
			? $this->properties['value-type']
38 2
			: 'unknown';
39
	}
40
41
	/**
42
	 * @see AbstractNode::equals
43
	 */
44 3
	public function equals($target) {
45 3
		return $target instanceof self && $this->properties == $target->properties;
46
	}
47
}
48