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

AlertPublisher   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 87
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 87
rs 10
c 0
b 0
f 0
wmc 12

11 Methods

Rating   Name   Duplication   Size   Complexity  
A valid() 0 3 1
A next() 0 3 1
A offsetExists() 0 3 1
A rewind() 0 3 1
A offsetGet() 0 3 2
A count() 0 3 1
A offsetSet() 0 3 1
A key() 0 3 1
A current() 0 3 1
A __construct() 0 3 1
A offsetUnset() 0 3 1
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