Completed
Push — master ( e6bfbd...af89b1 )
by recca
03:06
created

LaravelSession::start()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 6
ccs 0
cts 3
cp 0
crap 2
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Recca0120\Elfinder;
4
5
use elFinderSessionInterface;
6
use Illuminate\Session\SessionManager;
7
8
class LaravelSession implements elFinderSessionInterface
9
{
10
    /**
11
     * $session.
12
     *
13
     * @var \Illuminate\Session\SessionInterface
14
     */
15
    protected $session;
16
17
    /**
18
     * __construct.
19
     *
20
     * @param \Illuminate\Session\SessionManager $sessionManager
21
     */
22 1
    public function __construct(SessionManager $sessionManager)
23
    {
24 1
        $this->session = $sessionManager->driver();
25 1
    }
26
27
    /**
28
     * Session start.
29
     *
30
     * @return $this
31
     **/
32
    public function start()
33
    {
34
        $this->session->start();
35
36
        return $this;
37
    }
38
39
    /**
40
     * Session write & close.
41
     *
42
     * @return $this
43
     **/
44
    public function close()
45
    {
46
        $this->session->save();
47
48
        return $this;
49
    }
50
51
    /**
52
     * Get session data.
53
     *
54
     * This method must be equipped with an automatic start / close.
55
     *
56
     * @param string $key
57
     * @param mixed $empty
58
     * @return mixed
59
     **/
60
    public function get($key, $empty = '')
61
    {
62
        return $this->session->get($key, $empty);
63
    }
64
65
    /**
66
     * Set session data.
67
     *
68
     * This method must be equipped with an automatic start / close.
69
     *
70
     * @param string $key
71
     * @param mixed $data
72
     * @return $this
73
     **/
74
    public function set($key, $data)
75
    {
76
        $this->session->put($key, $data);
77
78
        return $this;
79
    }
80
81
    /**
82
     * Get session data.
83
     *
84
     * @param string $key
85
     * @return $this
86
     **/
87
    public function remove($key)
88
    {
89
        $this->session->remove($key);
90
91
        return $this;
92
    }
93
}
94