EntriesTrait::next()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Dwo\Aggregator\Model;
4
5
/**
6
 * Trait Entries
7
 *
8
 * @author Dave Www <[email protected]>
9
 */
10
trait EntriesTrait
11
{
12
    /**
13
     * @var array
14
     */
15
    protected $entries = [];
16
17
    /**
18
     * @return array
19
     */
20
    public function getEntries()
21
    {
22
        return (array) $this->entries;
23
    }
24
25
    /**
26
     * @param string $key
27
     *
28
     * @return mixed
29
     */
30
    public function getEntryByKey($key)
31
    {
32
        return isset($this->entries[$key]) ? $this->entries[$key] : null;
33
    }
34
35
    /**
36
     * @param string $key
37
     */
38
    public function removeEntryByKey($key)
39
    {
40
        if (isset($this->entries[$key])) {
41
            unset($this->entries[$key]);
42
        }
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48
    public function rewind()
49
    {
50
        return reset($this->entries);
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56
    public function current()
57
    {
58
        return current($this->entries);
59
    }
60
61
    /**
62
     * {@inheritdoc}
63
     */
64
    public function key()
65
    {
66
        return key($this->entries);
67
    }
68
69
    /**
70
     * {@inheritdoc}
71
     */
72
    public function next()
73
    {
74
        return next($this->entries);
75
    }
76
77
    /**
78
     * {@inheritdoc}
79
     */
80
    public function valid()
81
    {
82
        return key($this->entries) !== null;
83
    }
84
}