Completed
Branch 2.x (8ca90a)
by Julián
08:08
created

Memory::gc()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
/*
4
 * sessionware (https://github.com/juliangut/sessionware).
5
 * PSR7 compatible session management.
6
 *
7
 * @license BSD-3-Clause
8
 * @link https://github.com/juliangut/sessionware
9
 * @author Julián Gutiérrez <[email protected]>
10
 */
11
12
declare(strict_types=1);
13
14
namespace Jgut\Sessionware\Handler;
15
16
/**
17
 * In-memory session handler.
18
 */
19
class Memory implements Handler
20
{
21
    use HandlerTrait;
22
23
    /**
24
     * @var string
25
     */
26
    protected $data;
27
28
    /**
29
     * In-memory session handler constructor.
30
     */
31
    public function __construct()
32
    {
33
        $this->data = serialize([]);
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     *
39
     * @throws \RuntimeException
40
     *
41
     * @SuppressWarnings(PMD.UnusedFormalParameter)
42
     */
43
    public function open($savePath, $sessionName)
44
    {
45
        $this->testConfiguration();
46
47
        return true;
48
    }
49
50
    /**
51
     * {@inheritdoc}
52
     */
53
    public function close()
54
    {
55
        return true;
56
    }
57
58
    /**
59
     * {@inheritdoc}
60
     *
61
     * @SuppressWarnings(PMD.UnusedFormalParameter)
62
     */
63
    public function read($sessionId)
64
    {
65
        return $this->data;
66
    }
67
68
    /**
69
     * {@inheritdoc}
70
     *
71
     * @SuppressWarnings(PMD.UnusedFormalParameter)
72
     */
73
    public function write($sessionId, $sessionData)
74
    {
75
        $this->data = $sessionData;
76
77
        return true;
78
    }
79
80
    /**
81
     * {@inheritdoc}
82
     *
83
     * @SuppressWarnings(PMD.UnusedFormalParameter)
84
     */
85
    public function destroy($sessionId)
86
    {
87
        $this->data = serialize([]);
88
89
        return true;
90
    }
91
92
    /**
93
     * {@inheritdoc}
94
     *
95
     * @SuppressWarnings(PMD.ShortMethodName)
96
     * @SuppressWarnings(PMD.UnusedFormalParameter)
97
     */
98
    public function gc($maxLifetime)
99
    {
100
        return true;
101
    }
102
}
103