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 ( 2e415f...2c60a9 )
by Cees-Jan
09:33
created

ConstructListener   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 10

Importance

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

3 Methods

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