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

SessionHandler   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 36
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A read() 0 8 2
A write() 0 6 1
A destroy() 0 6 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