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 ( 3d0cda...b1828d )
by Cees-Jan
09:52
created

ConstructListener::construct()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 24
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 15
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 24
rs 8.9713
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\Authentication\AuthenticationManager;
19
use Thruway\Peer\Router;
20
use Thruway\Transport\RatchetTransportProvider;
21
use WyriHaximus\Ratchet\Security\AuthorizationManager;
22
use WyriHaximus\Ratchet\Security\WampCraAuthProvider;
23
use WyriHaximus\Ratchet\Websocket\InternalClient;
24
25
final class ConstructListener implements EventListenerInterface
26
{
27
    /**
28
     * @var Router
29
     */
30
    private $router;
31
32
    /**
33
     * @var LoopInterface
34
     */
35
    private $loop;
36
37
    /**
38
     * @return array
39
     */
40
    public function implementedEvents()
41
    {
42
        return [
43
            ConstructEvent::EVENT => 'construct',
44
        ];
45
    }
46
47
    /**
48
     * @param ConstructEvent $event
49
     */
50
    public function construct(ConstructEvent $event)
51
    {
52
        $this->loop = $event->getLoop();
53
        $this->router = new Router($this->loop);
54
55
        $this->router->registerModule(new AuthenticationManager());
56
57
        $realms = [];
58
        foreach (Configure::read('WyriHaximus.Ratchet.realms') as $realm => $config) {
59
            $realms[] = $realm;
60
            $this->setUpRealm($realm, $config, $event->getEventManager());
61
        }
62
        $this->router->addInternalClient(new WampCraAuthProvider($realms, $this->loop));
63
        $this->router->addTransportProvider(
64
            new RatchetTransportProvider(
65
                Configure::read('WyriHaximus.Ratchet.internal.address'),
66
                Configure::read('WyriHaximus.Ratchet.internal.port')
67
            )
68
        );
69
70
        $event->getEventManager()->dispatch(WebsocketStartEvent::create($this->loop));
71
72
        $this->router->start(false);
73
    }
74
75
    protected function setUpRealm($realm, array $config, EventManager $eventManager)
76
    {
77
        $internalClient = new InternalClient($realm, $this->loop);
78
        $internalClient->setEventManager($eventManager);
79
        $this->router->addInternalClient($internalClient);
80
        if (!\igorw\get_in($config, ['auth'], false)) {
81
            return;
82
        }
83
84
        $this->router->registerModule(new AuthorizationManager($realm, $this->loop));
85
    }
86
}