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
Push — thruway-0.4 ( 7c8224...62fb62 )
by Cees-Jan
08:39
created

ConstructListener   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 8

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 55
rs 10
wmc 5
lcom 1
cbo 8

3 Methods

Rating   Name   Duplication   Size   Complexity  
A implementedEvents() 0 6 1
A construct() 0 19 2
A setUpRealm() 0 9 2
1
<?php
2
3
/*
4
 * This file is part of Ratchet.
5
 *
6
 ** (c) 2016 Cees-Jan Kiewiet
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace WyriHaximus\Ratchet\Event;
13
14
use Cake\Core\Configure;
15
use Cake\Event\EventListenerInterface;
16
use Cake\Event\EventManager;
17
use React\EventLoop\LoopInterface;
18
use Thruway\Peer\Router;
19
use Thruway\Transport\RatchetTransportProvider;
20
use WyriHaximus\Ratchet\Security\AuthorizationManager;
21
use WyriHaximus\Ratchet\Websocket\InternalClient;
22
23
final class ConstructListener implements EventListenerInterface
24
{
25
    /**
26
     * @var Router
27
     */
28
    private $router;
29
30
    /**
31
     * @var LoopInterface
32
     */
33
    private $loop;
34
35
    /**
36
     * @return array
37
     */
38
    public function implementedEvents()
39
    {
40
        return [
41
            ConstructEvent::EVENT => 'construct',
42
        ];
43
    }
44
45
    /**
46
     * @param ConstructEvent $event
47
     */
48
    public function construct(ConstructEvent $event)
49
    {
50
        $this->loop = $event->getLoop();
51
        $this->router = new Router($this->loop);
52
53
        foreach (Configure::read('WyriHaximus.Ratchet.realms') as $realm => $config) {
54
            $this->setUpRealm($realm, $config);
55
        }
56
        $this->router->addTransportProvider(
57
            new RatchetTransportProvider(
58
                Configure::read('WyriHaximus.Ratchet.internal.address'),
59
                Configure::read('WyriHaximus.Ratchet.internal.port')
60
            )
61
        );
62
63
        EventManager::instance()->dispatch(WebsocketStartEvent::create($this->loop));
64
65
        $this->router->start(false);
66
    }
67
68
    protected function setUpRealm($realm, array $config)
69
    {
70
        $this->router->addInternalClient(new InternalClient($realm, $this->loop));
71
        if (!igorw\get_in($config, ['auth'], false)) {
72
            return;
73
        }
74
75
        $this->router->registerModule(new AuthorizationManager($realm, $this->loop));
76
    }
77
}