Passed
Push — master ( 6dedb2...9b1dd9 )
by Vitaly
06:42
created

IterableStructure::next()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
nc 1
cc 1
eloc 2
nop 0
crap 1
1
<?php declare(strict_types=1);
2
/**
3
 * Created by Vitaly Iegorov <[email protected]>.
4
 * on 07.04.17 at 09:08
5
 */
6
namespace samsonframework\stringconditiontree\string;
7
8
use Countable;
9
use Iterator;
10
11
/**
12
 * Class IterableStructure
13
 *
14
 * @author Vitaly Egorov <[email protected]>
15
 */
16
class IterableStructure implements Iterator, Countable
17
{
18
    /** @var AbstractCG[] */
19
    public $groups = [];
20
21
    /**
22
     * @inheritdoc
23
     */
24 2
    public function current()
25
    {
26 2
        return current($this->groups);
27
    }
28
29
    /**
30
     * @inheritdoc
31
     */
32 2
    public function next()
33
    {
34 2
        next($this->groups);
35 2
    }
36
37
    /**
38
     * @inheritdoc
39
     */
40 2
    public function key()
41
    {
42 2
        return key($this->groups);
43
    }
44
45
    /**
46
     * @inheritdoc
47
     */
48 2
    public function valid()
49
    {
50 2
        $key = key($this->groups);
51
52 2
        return ($key !== null && $key !== false);
53
    }
54
55
    /**
56
     * @inheritdoc
57
     */
58 2
    public function rewind()
59
    {
60 2
        reset($this->groups);
61 2
    }
62
63
    /**
64
     * @inheritdoc
65
     */
66 2
    public function count()
67
    {
68 2
        return count($this->groups);
69
    }
70
}
71