GenericIterator   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 77
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 6
eloc 11
dl 0
loc 77
ccs 13
cts 13
cp 1
rs 10
c 2
b 1
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A current() 0 4 1
A valid() 0 4 1
A toArray() 0 9 2
A next() 0 3 1
A rewind() 0 3 1
1
<?php
2
3
namespace ByJG\AnyDataset\Core;
4
5
use Iterator;
6
7
abstract class GenericIterator implements IteratorInterface, Iterator
8
{
9
10
    /**
11
     * @inheritDoc
12
     */
13
    abstract public function hasNext();
14
15
    /**
16
     * @inheritDoc
17
     */
18
    abstract public function moveNext();
19
20
    /**
21
     * @inheritDoc
22
     */
23
    abstract public function count();
24
25
    /**
26
     * @inheritDoc
27
     */
28
    #[\ReturnTypeWillChange]
29
    abstract public function key();
30
31
    /**
32
     * @inheritDoc
33
     * @throws \ByJG\Serializer\Exception\InvalidArgumentException
34
     */
35 14
    public function toArray($fields = [])
36
    {
37 14
        $retArray = [];
38
39 14
        foreach ($this as $singleRow) {
40 14
            $retArray[] = $singleRow->toArray($fields);
41
        }
42
    
43 14
        return $retArray;
44
    }
45
46
    /* ------------------------------------- */
47
    /* PHP 5 Specific functions for Iterator */
48
    /* ------------------------------------- */
49
50
    /**
51
     * @return mixed
52
     */
53
    #[\ReturnTypeWillChange]
54 15
    public function current()
55
    {
56 15
        return $this->moveNext();
57
    }
58
59
    /**
60
     * @inheritDoc
61
     */
62
    #[\ReturnTypeWillChange]
63 15
    public function rewind()
64
    {
65
        // There is no necessary
66 15
    }
67
68
    /**
69
     * @inheritDoc
70
     */
71
    #[\ReturnTypeWillChange]
72 15
    public function next()
73
    {
74
        // There is no necessary
75 15
    }
76
77
    /**
78
     * @inheritDoc
79
     */
80
    #[\ReturnTypeWillChange]
81 15
    public function valid()
82
    {
83 15
        return $this->hasNext();
84
    }
85
}
86