Completed
Branch 2.x (525e63)
by Julián
09:21
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 session management middleware.
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\Middleware\Sessionware\Handler;
15
16
/**
17
 * In-memory session handler.
18
 */
19
class Memory implements Handler
20
{
21
    use HandlerTrait;
22
23
    /**
24
     * @var array
25
     */
26
    protected $data = [];
27
28
    /**
29
     * {@inheritdoc}
30
     *
31
     * @throws \RuntimeException
32
     */
33
    public function open($savePath, $sessionName)
34
    {
35
        $this->testConfiguration();
36
37
        return true;
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43
    public function close()
44
    {
45
        return true;
46
    }
47
48
    /**
49
     * {@inheritdoc}
50
     */
51
    public function read($sessionId)
52
    {
53
        return serialize($this->data);
54
    }
55
56
    /**
57
     * {@inheritdoc}
58
     */
59
    public function write($sessionId, $sessionData)
60
    {
61
        $this->data = unserialize($sessionData);
62
63
        return true;
64
    }
65
66
    /**
67
     * {@inheritdoc}
68
     */
69
    public function destroy($sessionId)
70
    {
71
        $this->data = [];
72
73
        return true;
74
    }
75
76
    /**
77
     * {@inheritdoc}
78
     *
79
     * @SuppressWarnings(PMD.ShortMethodName)
80
     */
81
    public function gc($maxLifetime)
82
    {
83
        return true;
84
    }
85
}
86