BooleanResourceNode   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 92.31%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 42
c 0
b 0
f 0
ccs 12
cts 13
cp 0.9231
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 2
A getBooleanValue() 0 3 1
A getValueType() 0 3 1
A equals() 0 4 2
1
<?php
2
3
namespace PPP\DataModel;
4
5
use InvalidArgumentException;
6
7
/**
8
 * A boolean resource node.
9
 *
10
 * @licence AGPLv3+
11
 * @author Thomas Pellissier Tanon
12
 */
13
class BooleanResourceNode extends ResourceNode {
14
15
	/**
16
	 * @var bool
17
	 */
18
	private $booleanValue;
19
20
	/**
21
	 * @param string $value
22
	 */
23 5
	public function __construct($value) {
24 5
		$this->booleanValue = filter_var($value, FILTER_VALIDATE_BOOLEAN,  	FILTER_NULL_ON_FAILURE);
25
26 5
		if($this->booleanValue === null) {
27
			throw new InvalidArgumentException("Invalid value for BooleanResourceNode");
28
		}
29
30 5
		parent::__construct($value);
31 5
	}
32
33
	/**
34
	 * @return bool
35
	 */
36 1
	public function getBooleanValue() {
37 1
		return $this->booleanValue;
38
	}
39
40
	/**
41
	 * @return string
42
	 */
43 1
	public function getValueType() {
44 1
		return 'boolean';
45
	}
46
47
	/**
48
	 * @see AbstractNode::equals
49
	 */
50 3
	public function equals($target) {
51 3
		return $target instanceof self &&
52 3
		$this->booleanValue === $target->booleanValue;
53
	}
54
}
55