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

SessionStateStorage::get()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
ccs 2
cts 2
cp 1
crap 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