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