Session::processResponse()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 4
cp 0
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 2
nop 2
crap 6
1
<?php
2
3
namespace BrainExe\Core\Middleware;
4
5
use BrainExe\Core\Annotations\Inject;
6
use BrainExe\Core\Annotations\Middleware;
7
use Symfony\Component\HttpFoundation\Request;
8
use Symfony\Component\HttpFoundation\Response;
9
use Symfony\Component\HttpFoundation\Session\Session as SessionModel;
10
use Symfony\Component\Routing\Route;
11
12
/**
13
 * @Middleware("Middleware.Session")
14
 */
15
class Session extends AbstractMiddleware
16
{
17
18
    /**
19
     * @var SessionModel
20
     */
21
    private $session;
22
23
    /**
24
     * @Inject({"@RedisSession"})
25
     * @param SessionModel $session
26
     */
27 1
    public function __construct(SessionModel $session)
28
    {
29 1
        $this->session = $session;
30 1
    }
31
32
    /**
33
     * {@inheritdoc}
34
     */
35 1
    public function processRequest(Request $request, Route $route)
36
    {
37 1
        $request->setSession($this->session);
38 1
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43
    public function processResponse(Request $request, Response $response)
44
    {
45
        if ($this->session->isStarted()) {
46
            $this->session->save();
47
        }
48
    }
49
}
50