Completed
Push — master ( 091f4b...212c6c )
by Matze
03:51
created

SessionHandler::read()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4286
cc 2
eloc 4
nc 2
nop 1
1
<?php
2
3
namespace BrainExe\Core\Application;
4
5
use Predis\Session\Handler;
6
7
class SessionHandler extends Handler
8
{
9
10
    const KEY = 'sessions:';
11
12
    /**
13
     * {@inheritdoc}
14
     */
15
    public function read($sessionId)
16
    {
17
        if ($data = $this->client->get(self::KEY . $sessionId)) {
18
            return $data;
19
        }
20
21
        return '';
22
    }
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function write($sessionId, $sessionData)
27
    {
28
        $this->client->setex(self::KEY . $sessionId, $this->ttl, $sessionData);
29
30
        return true;
31
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    public function destroy($sessionId)
37
    {
38
        $this->client->del(self::KEY . $sessionId);
39
40
        return true;
41
    }
42
}
43