LaminasSessionTokenStorage   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
c 0
b 0
f 0
dl 0
loc 27
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A store() 0 3 1
A retrieve() 0 10 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PublishingKit\Csrf;
6
7
use Laminas\Session\Container;
8
9
final class LaminasSessionTokenStorage implements TokenStorage
10
{
11
    /**
12
     * @var Container
13
     */
14
    private $session;
15
16
    public function __construct(Container $session)
17
    {
18
        $this->session = $session;
19
    }
20
21
    public function store(string $key, Token $token): void
22
    {
23
        $this->session->$key = $token->__toString();
24
    }
25
26
    public function retrieve(string $key): ?Token
27
    {
28
        /** @var string|null **/
29
        $tokenValue = $this->session->$key;
30
31
        if ($tokenValue === null) {
32
            return null;
33
        }
34
35
        return new Token($tokenValue);
36
    }
37
}
38