SessionProvider   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A get() 0 6 1
1
<?php
2
3
namespace Ray\SymfonySessionModule;
4
5
use Ray\Di\ProviderInterface;
6
use Ray\SymfonySessionModule\Annotation\SessionOptions;
7
use Symfony\Component\HttpFoundation\Session\Session;
8
use Symfony\Component\HttpFoundation\Session\SessionInterface;
9
use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;
10
11
class SessionProvider implements ProviderInterface
12
{
13
    /**
14
     * @var \SessionHandlerInterface
15
     */
16
    private $handler;
17
18
    /**
19
     * @var array
20
     */
21
    private $options;
22
23
    /**
24
     * Constructor
25
     *
26
     * @param \SessionHandlerInterface $handler
27
     * @param array                    $options
28
     *
29
     * @SessionOptions("options")
30
     */
31 1
    public function __construct(\SessionHandlerInterface $handler, array $options = [])
32
    {
33 1
        $this->handler = $handler;
34 1
        $this->options = $options;
35 1
    }
36
37
    /**
38
     * @return SessionInterface
39
     */
40 1
    public function get()
41
    {
42 1
        $storage = new NativeSessionStorage($this->options, $this->handler);
43
44 1
        return new Session($storage);
45
    }
46
}
47