Passed
Push — master ( 13425d...f357db )
by Alexander
02:26
created

SessionStateStorage   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 31
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A set() 0 3 1
A get() 0 3 1
A remove() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Yii\AuthClient\StateStorage;
6
7
use Yiisoft\Session\SessionInterface;
8
9
/**
10
 * SessionStateStorage provides Auth client state storage based on web session.
11
 *
12
 * @see StateStorageInterface
13
 * @see SessionInterface
14
 */
15
class SessionStateStorage implements StateStorageInterface
16
{
17
    /**
18
     * @var SessionInterface session object to be used.
19
     *
20
     * After the SessionStateStorage object is created, if you want to change this property,
21
     * you should only assign it with a session object.
22
     *
23
     * If not set - application 'session' component will be used, but only, if it is available (e.g. in web application),
24
     * otherwise - no session will be used and no data saving will be performed.
25
     */
26
    private SessionInterface $session;
27
28 10
    public function __construct(SessionInterface $session)
29
    {
30 10
        $this->session = $session;
31 10
    }
32
33 2
    public function set(string $key, $value): void
34
    {
35 2
        $this->session->set($key, $value);
36 2
    }
37
38 3
    public function get(string $key)
39
    {
40 3
        return $this->session->get($key);
41
    }
42
43 1
    public function remove(string $key): void
44
    {
45 1
        $this->session->remove($key);
46 1
    }
47
}
48