Completed
Push — master ( 0e1c32...e580ff )
by T
05:02
created

Node   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 76.47%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 7
c 1
b 0
f 1
lcom 0
cbo 1
dl 0
loc 32
ccs 13
cts 17
cp 0.7647
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
C isEqual() 0 29 7
1
<?php
2
3
namespace PHPSemVerChecker\Comparator;
4
5
class Node
6
{
7 8
	public static function isEqual(\PhpParser\Node $nodeA, \PhpParser\Node $nodeB)
8
	{
9 8
		if ($nodeA->getType() !== $nodeB->getType()) {
10
			return false;
11
		}
12
13 8
		$subNodesA = $nodeA->getSubNodeNames();
14 8
		$subNodesB = $nodeB->getSubNodeNames();
15 8
		if ($subNodesA !== $subNodesB) {
16
			return false;
17
		}
18
19 8
		foreach ($subNodesA as $key) {
20 8
			$valueA = $nodeA->$key;
21 8
			$valueB = $nodeB->$key;
22 8
			$result = true;
0 ignored issues
show
Unused Code introduced by
$result is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
23 8
			if ($valueA instanceof \PhpParser\Node && $valueB instanceof \PhpParser\Node) {
24
				$result = self::isEqual($valueA, $valueB);
25
			} else {
26 8
				$result = $valueA === $valueB;
27
			}
28
29 8
			if ( ! $result) {
30 8
				return false;
31
			}
32
		}
33
34
		return true;
35
	}
36
}
37