GenericIterator::valid()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 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