Completed
Push — master ( 411617...e3a891 )
by Joao
06:19 queued 04:00
created

GenericIterator::next()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

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
nc 1
nop 0
crap 1
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 9
    public function toArray()
24
    {
25 9
        $retArray = [];
26
27 9
        while ($this->hasNext()) {
28 9
            $singleRow = $this->moveNext();
29 9
            $retArray[] = $singleRow->toArray();
30
        }
31
32 9
        return $retArray;
33
    }
34
    /* ------------------------------------- */
35
    /* PHP 5 Specific functions for Iterator */
36
    /* ------------------------------------- */
37
38
    /**
39
     * @return Row
40
     */
41 1
    public function current()
42
    {
43 1
        return $this->moveNext();
44
    }
45
46 1
    public function rewind()
47
    {
48
        // There is no necessary
49 1
    }
50
51 1
    public function next()
52
    {
53
        // There is no necessary
54 1
    }
55
56 1
    public function valid()
57
    {
58 1
        return $this->hasNext();
59
    }
60
}
61