NullEventManager::getSharedManager()   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 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Abacaphiliac\Zend\EventManager\PluginManager;
4
5
use Traversable;
6
use Zend\EventManager\EventManagerInterface;
7
use Zend\EventManager\ListenerAggregateInterface;
8
use Zend\EventManager\ResponseCollection;
9
use Zend\EventManager\SharedEventManagerAwareInterface;
10
use Zend\EventManager\SharedEventManagerInterface;
11
use Zend\Stdlib\CallbackHandler;
12
13
class NullEventManager implements EventManagerInterface
14
{
15
    /** @var  SharedEventManagerInterface */
16
    private $sharedEventManager;
17
18
    /**
19
     * NullEventManager constructor.
20
     * @param SharedEventManagerInterface $sharedEventManager
21
     */
22 22
    public function __construct(SharedEventManagerInterface $sharedEventManager)
23
    {
24 22
        $this->sharedEventManager = $sharedEventManager;
25 22
    }
26
27
    /**
28
     * Trigger an event
29
     *
30
     * Should allow handling the following scenarios:
31
     * - Passing Event object only
32
     * - Passing event name and Event object only
33
     * - Passing event name, target, and Event object
34
     * - Passing event name, target, and array|ArrayAccess of arguments
35
     *
36
     * Can emulate triggerUntil() if the last argument provided is a callback.
37
     *
38
     * @param  string $event
39
     * @param  object|string $target
40
     * @param  array|object $argv
41
     * @param  null|callable $callback
42
     * @return ResponseCollection
43
     */
44 1
    public function trigger($event, $target = null, $argv = array(), $callback = null)
45
    {
46 1
        return new ResponseCollection();
47
    }
48
49
    /**
50
     * Trigger an event until the given callback returns a boolean false
51
     *
52
     * Should allow handling the following scenarios:
53
     * - Passing Event object and callback only
54
     * - Passing event name, Event object, and callback only
55
     * - Passing event name, target, Event object, and callback
56
     * - Passing event name, target, array|ArrayAccess of arguments, and callback
57
     *
58
     * @param  string $event
59
     * @param  object|string $target
60
     * @param  array|object $argv
61
     * @param  callable $callback
62
     * @return ResponseCollection
63
     */
64 1
    public function triggerUntil($event, $target, $argv = null, $callback = null)
65
    {
66 1
        return new ResponseCollection();
67
    }
68
69
    /**
70
     * Attach a listener to an event
71
     *
72
     * @param  string $event
73
     * @param  callable $callback
74
     * @param  int $priority Priority at which to register listener
75
     * @return CallbackHandler
76
     */
77
    public function attach($event, $callback = null, $priority = 1)
78
    {
79 2
        return new CallbackHandler(function () {
0 ignored issues
show
Deprecated Code introduced by
The class Zend\Stdlib\CallbackHandler has been deprecated with message: as of v2.7.4.

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
80
            
81 2
        });
82
    }
83
84
    /**
85
     * Detach an event listener
86
     *
87
     * @param  CallbackHandler|ListenerAggregateInterface $listener
88
     * @return bool
89
     */
90 1
    public function detach($listener)
91
    {
92 1
        return true;
93
    }
94
95
    /**
96
     * Get a list of events for which this collection has listeners
97
     *
98
     * @return array
99
     */
100 3
    public function getEvents()
101
    {
102 3
        return array();
103
    }
104
105
    /**
106
     * Retrieve a list of listeners registered to a given event
107
     *
108
     * @param  string $event
109
     * @return array|object
110
     */
111 1
    public function getListeners($event)
112
    {
113 1
        return array();
114
    }
115
116
    /**
117
     * Clear all listeners for a given event
118
     *
119
     * @param  string $event
120
     * @return void
121
     */
122 1
    public function clearListeners($event)
123
    {
124
125 1
    }
126
127
    /**
128
     * Set the event class to utilize
129
     *
130
     * @param  string $class
131
     * @return EventManagerInterface
132
     */
133 1
    public function setEventClass($class)
134
    {
135 1
        return $this;
136
    }
137
138
    /**
139
     * Get the identifier(s) for this EventManager
140
     *
141
     * @return array
142
     */
143 3
    public function getIdentifiers()
144
    {
145 3
        return array();
146
    }
147
148
    /**
149
     * Set the identifiers (overrides any currently set identifiers)
150
     *
151
     * @param string|int|array|Traversable $identifiers
152
     * @return EventManagerInterface
153
     */
154 2
    public function setIdentifiers($identifiers)
155
    {
156 2
        return $this;
157
    }
158
159
    /**
160
     * Add some identifier(s) (appends to any currently set identifiers)
161
     *
162
     * @param string|int|array|Traversable $identifiers
163
     * @return EventManagerInterface
164
     */
165 2
    public function addIdentifiers($identifiers)
166
    {
167 2
        return $this;
168
    }
169
170
    /**
171
     * Attach a listener aggregate
172
     *
173
     * @param  ListenerAggregateInterface $aggregate
174
     * @param  int $priority If provided, a suggested priority for the aggregate to use
175
     * @return void return value of {@link ListenerAggregateInterface::attach()}
176
     */
177 2
    public function attachAggregate(ListenerAggregateInterface $aggregate, $priority = 1)
178
    {
179
        
180 2
    }
181
182
    /**
183
     * Detach a listener aggregate
184
     *
185
     * @param  ListenerAggregateInterface $aggregate
186
     * @return void return value of {@link ListenerAggregateInterface::detach()}
187
     */
188 1
    public function detachAggregate(ListenerAggregateInterface $aggregate)
189
    {
190
        
191 1
    }
192
193
    /**
194
     * Inject a SharedEventManager instance
195
     *
196
     * @param  SharedEventManagerInterface $sharedEventManager
197
     * @return SharedEventManagerAwareInterface
198
     */
199 1
    public function setSharedManager(SharedEventManagerInterface $sharedEventManager)
200
    {
201 1
        $this->sharedEventManager = $sharedEventManager;
202
        
203 1
        return $this;
204
    }
205
206
    /**
207
     * Get shared collections container
208
     *
209
     * @return SharedEventManagerInterface
210
     */
211 3
    public function getSharedManager()
212
    {
213 3
        return $this->sharedEventManager;
214
    }
215
216
    /**
217
     * Remove any shared collections
218
     *
219
     * @return void
220
     */
221 1
    public function unsetSharedManager()
222
    {
223 1
        $this->sharedEventManager = null;
224 1
    }
225
}
226