ChannelAuthenticator   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 1
cbo 1
dl 0
loc 31
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A authenticate() 0 10 1
1
<?php
2
3
/*
4
 * This file is part of `Composer as a service`.
5
 *
6
 * (c) Pascal Borreli <[email protected]>
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 Ayaline\Bundle\ComposerBundle\Pusher;
13
14
use Lopi\Bundle\PusherBundle\Authenticator\ChannelAuthenticatorInterface;
15
use Symfony\Component\HttpFoundation\RequestStack;
16
17
class ChannelAuthenticator implements ChannelAuthenticatorInterface
18
{
19
    protected $requestStack;
20
21
    /**
22
     * Constructor.
23
     *
24
     * @param RequestStack $requestStack A RequestStack instance
25
     */
26
    public function __construct(RequestStack $requestStack)
27
    {
28
        $this->requestStack = $requestStack;
29
    }
30
31
    /**
32
     * @param string $socketId
33
     * @param string $channelName
34
     *
35
     * @return bool
36
     */
37
    public function authenticate($socketId, $channelName)
38
    {
39
        $request = $this->requestStack->getCurrentRequest();
40
        $session = $request->getSession();
41
42
        $session->set('socketId', $socketId);
43
        $session->set('channelName', $channelName);
44
45
        return true;
46
    }
47
}
48