SessionalInterceptor   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 3
c 2
b 1
f 0
lcom 1
cbo 5
dl 0
loc 24
ccs 9
cts 9
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A invoke() 0 16 3
1
<?php
2
3
namespace Ray\SymfonySessionModule;
4
5
use Ray\Aop\MethodInterceptor;
6
use Ray\Aop\MethodInvocation;
7
use Ray\SymfonySessionModule\Exception\SessionExpiredException;
8
9
class SessionalInterceptor implements MethodInterceptor
10
{
11
    use SessionInject;
12
13
    /**
14
     * {@inheritdoc}
15
     */
16 4
    public function invoke(MethodInvocation $invocation)
17
    {
18 4
        $this->session->start();
19
20 4
        $metadataBag = $this->session->getMetadataBag();
21 4
        $lifetime = $metadataBag->getLifetime();
22
23 4
        if ($lifetime > 0 && $metadataBag->getLastUsed() + $lifetime < time()) {
24 1
            $this->session->invalidate();
25 1
            throw new SessionExpiredException('Session has expired.');
26
        }
27
28 3
        $this->session->migrate();
29
30 3
        return $invocation->proceed();
31
    }
32
}
33