Passed
Pull Request — master (#10)
by Joao
01:36
created

GenericIterator::next()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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