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.

EventContainer   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getListeners() 0 4 2
A hasEvent() 0 4 1
A addListener() 0 12 3
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
    /** @psalm-var array<string,list<callable>> */
12
    private $listeners = array();
13
14 9
    public function __construct()
15
    {
16 9
    }
17
18
    /**
19
     * @param string $event
20
     * @param callable $handler
21
     *
22
     * @return void
23
     */
24 5
    public function addListener($event, $handler)
25
    {
26 5
        if(!\in_array($event, Events::getEvents(), true)) {
27 1
            throw new \InvalidArgumentException(sprintf('Unsupported event %s!', $event));
28
        }
29
30 4
        if(!array_key_exists($event, $this->listeners)) {
31 4
            $this->listeners[$event] = array();
32 4
        }
33
34 4
        $this->listeners[$event][] = $handler;
35 4
    }
36
37
    /**
38
     * @param string $event
39
     *
40
     * @psalm-return list<callable>
41
     */
42 5
    public function getListeners($event)
43
    {
44 5
        return $this->hasEvent($event) ? $this->listeners[$event] : array();
45
    }
46
47
    /**
48
     * @param string $name
49
     *
50
     * @return bool
51
     */
52 5
    private function hasEvent($name)
53
    {
54 5
        return array_key_exists($name, $this->listeners);
55
    }
56
}
57