LaravelSession   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A get() 0 4 1
A set() 0 6 1
A clear() 0 6 1
1
<?php
2
3
namespace Reallyli\AB\Session;
4
5
use Illuminate\Support\Facades\Session;
6
7
class LaravelSession implements SessionInterface
8
{
9
    /**
10
     * The session key.
11
     *
12
     * @var string
13
     */
14
    protected $sessionName = 'ab';
15
16
    /**
17
     * A copy of the session data.
18
     *
19
     * @var array
20
     */
21
    protected $data = null;
22
23
    /**
24
     * Constructor.
25
     */
26
    public function __construct()
27
    {
28
        $this->data = Session::get($this->sessionName, []);
0 ignored issues
show
Documentation Bug introduced by
It seems like \Illuminate\Support\Faca...->sessionName, array()) of type * is incompatible with the declared type array of property $data.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
29
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34
    public function get($name, $default = null)
35
    {
36
        return array_get($this->data, $name, $default);
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42
    public function set($name, $value)
43
    {
44
        $this->data[$name] = $value;
45
46
        return Session::set($this->sessionName, $this->data);
47
    }
48
49
    /**
50
     * {@inheritdoc}
51
     */
52
    public function clear()
53
    {
54
        $this->data = [];
55
56
        return Session::forget($this->sessionName);
57
    }
58
}
59