GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#32)
by Tomasz
04:40
created

EventContainer::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

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 3
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 1
nc 1
nop 0
crap 1
1
<?php
2
namespace Thunder\Shortcode\EventContainer;
3
4
use Thunder\Shortcode\Events;
5
6
/**
7
 * @author Tomasz Kowalczyk <[email protected]>
8
 */
9
final class EventContainer implements EventContainerInterface
10
{
11
    private $listeners = array();
12
13 5
    public function __construct()
14
    {
15 5
    }
16
17 5
    public function addListener($event, $handler)
18
    {
19 5
        if(!in_array($event, Events::getEvents())) {
20 1
            throw new \InvalidArgumentException(sprintf('Unsupported event %s!', $event));
21
        }
22
23 4
        if(!array_key_exists($event, $this->listeners)) {
24 4
            $this->listeners[$event] = array();
25 4
        }
26
27 4
        $this->listeners[$event][] = $handler;
28 4
    }
29
30 4
    public function getListeners($event)
31
    {
32 4
        return $this->hasEvent($event) ? $this->listeners[$event] : array();
33
    }
34
35 4
    private function hasEvent($name)
36
    {
37 4
        return array_key_exists($name, $this->listeners);
38
    }
39
}
40