TimeResourceNode::__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 time resource node.
7
 *
8
 * @licence AGPLv3+
9
 * @author Thomas Pellissier Tanon
10
 */
11
class TimeResourceNode extends ResourceNode {
12
13
	/**
14
	 * @var string
15
	 */
16
	private $calendar;
17
18
	/**
19
	 * @param string $value
20
	 * @param string $calendar
21
	 */
22 5
	public function __construct($value, $calendar = 'gregorian') {
23 5
		$this->calendar = $calendar;
24
25 5
		parent::__construct($value);
26 5
	}
27
28
	/**
29
	 * @return string
30
	 */
31 1
	public function getCalendar() {
32 1
		return $this->calendar;
33
	}
34
35
	/**
36
	 * @return string
37
	 */
38 1
	public function getValueType() {
39 1
		return 'time';
40
	}
41
42
	/**
43
	 * @see AbstractNode::equals
44
	 */
45 3
	public function equals($target) {
46 3
		return $target instanceof self &&
47 3
			$this->getValue() === $target->getValue() &&
48 3
			$this->calendar === $target->calendar;
49
	}
50
}
51