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
02:27
created

EventContainer   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 7
c 1
b 0
f 1
lcom 1
cbo 1
dl 0
loc 31
ccs 14
cts 14
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A addListener() 0 12 3
A getListeners() 0 4 2
A hasEvent() 0 4 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