OperatorNode   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 9
lcom 1
cbo 1
dl 0
loc 45
c 0
b 0
f 0
ccs 0
cts 19
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getOperands() 0 3 1
B equals() 0 20 7
1
<?php
2
3
namespace PPP\DataModel;
4
5
/**
6
 * An operator node.
7
 *
8
 * @licence AGPLv3+
9
 * @author Thomas Pellissier Tanon
10
 */
11
abstract class OperatorNode extends AbstractNode {
12
13
	/**
14
	 * @var AbstractNode[]
15
	 */
16
	private $operands;
17
18
	/**
19
	 * @param AbstractNode[] $operands
20
	 */
21
	public function __construct($operands) {
22
		$this->operands = $operands;
23
	}
24
25
	/**
26
	 * @return AbstractNode[]
27
	 */
28
	public function getOperands() {
29
		return $this->operands;
30
	}
31
32
	/**
33
	 * @see AbstractNode::equals
34
	 */
35
	public function equals($target) {
36
		if(!($target instanceof self) || count($this->operands) !== count($target->operands)) {
37
			return false;
38
		}
39
40
		foreach($this->operands as $operand1) {
41
			$matched = false;
42
			foreach($this->operands as $operand2) {
43
				if($operand1->equals($operand2)) {
44
					$matched = true;
45
					break;
46
				}
47
			}
48
			if(!$matched) {
49
				return false;
50
			}
51
		}
52
53
		return true;
54
	}
55
}
56