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

GenericIterator   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 53
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0

9 Methods

Rating   Name   Duplication   Size   Complexity  
hasNext() 0 1 ?
moveNext() 0 1 ?
count() 0 1 ?
key() 0 1 ?
A toArray() 0 11 2
A current() 0 4 1
A rewind() 0 4 1
A next() 0 4 1
A valid() 0 4 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