DebugListener::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 0
cts 5
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 2
1
<?php
2
3
namespace Happyr\ApiBundle\Security\Firewall;
4
5
use Happyr\ApiBundle\Service\ResponseFactory;
6
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
7
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
8
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
9
use Symfony\Component\Security\Http\Firewall\ListenerInterface;
10
use Happyr\ApiBundle\Security\Authentication\Token\WsseUserToken;
11
12
/**
13
 * @author Tobias Nyholm <[email protected]>
14
 */
15
class DebugListener implements ListenerInterface
16
{
17
    /**
18
     * @var TokenStorageInterface
19
     */
20
    protected $tokenStorage;
21
22
    /**
23
     * @var AuthenticationManagerInterface
24
     */
25
    protected $authenticationManager;
26
27
    /**
28
     * WsseListener constructor.
29
     *
30
     * @param TokenStorageInterface          $tokenStorage
31
     * @param AuthenticationManagerInterface $authenticationManager
32
     */
33
    public function __construct(TokenStorageInterface $tokenStorage, AuthenticationManagerInterface $authenticationManager)
34
    {
35
        $this->tokenStorage = $tokenStorage;
36
        $this->authenticationManager = $authenticationManager;
37
    }
38
39
    /**
40
     * @param GetResponseEvent $event
41
     */
42
    public function handle(GetResponseEvent $event)
43
    {
44
        $token = new WsseUserToken();
45
        $token->setUser('api_user');
46
47
        $authToken = $this->authenticationManager->authenticate($token);
48
        $this->tokenStorage->setToken($authToken);
49
    }
50
51
    /**
52
     * @param ResponseFactory $responseFactory
53
     **/
54
    public function setResponseFactory(ResponseFactory $responseFactory)
0 ignored issues
show
Unused Code introduced by
The parameter $responseFactory is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
55
    {
56
    }
57
}
58