Conditions | 5 |
Paths | 6 |
Total Lines | 18 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
16 | public function getIterator() |
||
17 | { |
||
18 | $result = new \ArrayIterator(); |
||
19 | $this->iterator->rewind(); |
||
20 | $index = 0; |
||
|
|||
21 | while ($this->iterator->getIndex() < $this->count && $this->iterator->valid()) { |
||
22 | $result->append($this->iterator->current()); |
||
23 | $this->iterator->next(); |
||
24 | } |
||
25 | while ($this->iterator->valid()) { |
||
26 | $newIndex = (int) rand(0, $this->iterator->getIndex()); |
||
27 | if ($newIndex < $this->count) { |
||
28 | $result[$newIndex] = $this->iterator->current(); |
||
29 | } |
||
30 | $this->iterator->next(); |
||
31 | } |
||
32 | return $result; |
||
33 | } |
||
34 | } |
||
35 |
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.