SessionManager   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 26
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A has() 0 3 1
A get() 0 3 1
A unset() 0 3 1
A set() 0 3 1
A __construct() 0 3 1
1
<?php
2
namespace MyWonderland\Domain\Manager;
3
4
/**
5
 * Created by PhpStorm.
6
 * User: thiago
7
 * Date: 01/04/18
8
 * Time: 10:56
9
 */
10
11
/**
12
 * Class SessionManager
13
 * @package MyWonderland\Domain\Manager
14
 *
15
 * (from PHP docs): Caution -- If you turn on session.auto_start then the only way to put objects
16
 * into your sessions is to load its class definition using auto_prepend_file in which you load
17
 * the class definition else you will have to serialize() your object and unserialize() it afterwards.
18
 * http://php.net/manual/en/intro.session.php
19
 */
20
class SessionManager implements StorageManager
21
{
22
    // @todo improve security
23
    function __construct()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
24
    {
25
        session_start();
26
    }
27
28
    function set($key, $value)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
29
    {
30
        $_SESSION[$key] = serialize($value);
31
    }
32
33
    function get($key)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
34
    {
35
        return unserialize($_SESSION[$key]);
36
    }
37
38
    function has($key)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
39
    {
40
        return isset($_SESSION[$key]);
41
    }
42
43
    function unset($key)
44
    {
45
        unset($_SESSION[$key]);
46
    }
47
}