Completed
Pull Request — master (#2)
by Joao
05:22
created

GenericIterator::rewind()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace ByJG\AnyDataset\Dataset;
4
5
use ByJG\AnyDataset\IteratorInterface;
6
use ByJG\Serializer\DumpToArrayInterface;
7
use Iterator;
8
9
abstract class GenericIterator implements IteratorInterface, Iterator, DumpToArrayInterface
10
{
11
12
    abstract public function hasNext();
13
14
    abstract public function moveNext();
15
16
    abstract public function count();
17
18
    abstract public function key();
19
20 22
    public function toArray()
21
    {
22 22
        $retArray = [];
23
24 22
        while ($this->hasNext()) {
25 21
            $singleRow = $this->moveNext();
26 21
            $retArray[] = $singleRow->toArray();
27 21
        }
28
29 22
        return $retArray;
30
    }
31
    /* ------------------------------------- */
32
    /* PHP 5 Specific functions for Iterator */
33
    /* ------------------------------------- */
34
35
    /**
36
     * @return Row
37
     */
38 15
    public function current()
39
    {
40 15
        return $this->moveNext();
41
    }
42
43 16
    public function rewind()
44
    {
45
        // There is no necessary
46 16
    }
47
48 15
    public function next()
49
    {
50
        // There is no necessary
51 15
    }
52
53 16
    public function valid()
54
    {
55 16
        return $this->hasNext();
56
    }
57
}
58