GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Session::save()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php declare(strict_types=1);
2
/**
3
 * @license MIT
4
 * @author Samuel Adeshina <[email protected]>
5
 *
6
 * This file is part of the EmmetBlue project, please read the license document
7
 * available in the root level of the project
8
 */
9
namespace EmmetBlue\Core\Session;
10
11
/**
12
 * Class Session
13
 *
14
 * @author Samuel Adeshina <[email protected]>
15
 *
16
 * @since v0.0.1 08/06/2016 14:20
17
 */
18
class Session
19
{
20
    protected $session;
21
    
22
    /**
23
     * 
24
     */
25
    public static function init($session = "")
26
    {
27
        $this->session = $session;
0 ignored issues
show
Bug introduced by
The variable $this does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
28
    }
29
    
30
    /**
31
     * 
32
     */
33
    public static function save($key, $value)
34
    {
35
        $session[$key] = $value;
0 ignored issues
show
Coding Style Comprehensibility introduced by
$session was never initialized. Although not strictly required by PHP, it is generally a good practice to add $session = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
36
    }
37
38
    /**
39
     * 
40
     */
41
    public static function get($key)
42
    {
43
        return $session[$key] ?? '';
44
    }
45
46
    /**
47
     * 
48
     */
49
    public static function delete($key)
50
    {
51
       unset($session[$key]);
52
    }
53
}
54