Conditions | 4 |
Paths | 5 |
Total Lines | 17 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php |
||
36 | 5 | public function bind($eventName, $handler) |
|
37 | { |
||
38 | 5 | if (! self::isListener($handler)) { |
|
39 | 1 | throw new \LogicException('Invalid listener'); |
|
40 | } |
||
41 | |||
42 | 4 | if (false === array_key_exists($eventName, $this->bindings)) { |
|
43 | 4 | $this->bindings[$eventName] = new \SplObjectStorage(); |
|
44 | } |
||
45 | |||
46 | 4 | $listeners = $this->bindings[$eventName]; |
|
47 | |||
48 | 4 | if (! $listeners->offsetExists($handler)) { |
|
49 | 4 | $listeners->offsetSet($handler); |
|
50 | } |
||
51 | |||
52 | 4 | return $this; |
|
53 | } |
||
86 |