ChannelAuthenticator::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 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