Passed
Push — master ( db039c...4d8c20 )
by Dāvis
04:33
created

AlertPublisher::valid()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Sludio\HelperBundle\Script\Model;
4
5
class AlertPublisher implements \Iterator, \ArrayAccess, \Countable
6
{
7
    private $alerts;
8
9
    public function __construct(AlertManagerInterface $alertManager)
10
    {
11
        $this->alerts = $alertManager->getAlerts();
12
    }
13
14
    /**
15
     * @inheritdoc
16
     */
17
    public function current()
18
    {
19
        return current($this->alerts);
20
    }
21
22
    /**
23
     * @inheritdoc
24
     */
25
    public function next()
26
    {
27
        next($this->alerts);
28
    }
29
30
    /**
31
     * @inheritdoc
32
     */
33
    public function key()
34
    {
35
        return key($this->alerts);
36
    }
37
38
    /**
39
     * @inheritdoc
40
     */
41
    public function valid()
42
    {
43
        return key($this->alerts) !== null;
44
    }
45
46
    /**
47
     * @inheritdoc
48
     */
49
    public function rewind()
50
    {
51
        return reset($this->alerts);
52
    }
53
54
    /**
55
     * @inheritdoc
56
     */
57
    public function offsetExists($offset)
58
    {
59
        return isset($this->alerts[$offset]);
60
    }
61
62
    /**
63
     * @inheritdoc
64
     */
65
    public function offsetGet($offset)
66
    {
67
        return isset($this->alerts[$offset]) ? $this->alerts[$offset] : null;
68
    }
69
70
    /**
71
     * @inheritdoc
72
     */
73
    public function offsetSet($offset, $value)
74
    {
75
        $this->$this->alerts[$offset] = $value;
76
    }
77
78
    /**
79
     * @inheritdoc
80
     */
81
    public function offsetUnset($offset)
82
    {
83
        unset($this->alerts[$offset]);
84
    }
85
86
    /**
87
     * @inheritdoc
88
     */
89
    public function count()
90
    {
91
        return count($this->alerts);
92
    }
93
}
94