Conditions | 3 |
Paths | 3 |
Total Lines | 20 |
Lines | 0 |
Ratio | 0 % |
Tests | 2 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
36 | 50 | public function removeByName($name): bool |
|
37 | { |
||
38 | 50 | $this->rewind(); |
|
39 | |||
40 | while ($this->valid()) { |
||
41 | $field = $this->current(); |
||
42 | |||
43 | if ($field->getName() == $name) { |
||
44 | $key = $this->key(); |
||
45 | $this->offsetUnset($key); |
||
46 | $this->rewind(); |
||
47 | |||
48 | $result = true; |
||
|
|||
49 | } |
||
50 | } |
||
51 | |||
52 | $this->rewind(); |
||
53 | |||
54 | return false; |
||
55 | } |
||
56 | |||
64 | } |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
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.