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.

Storage   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
load() 0 1 ?
save() 0 1 ?
delete() 0 1 ?
A fresh() 0 4 1
A id() 0 14 3
1
<?php
2
/**
3
 * Pimf
4
 *
5
 * @copyright Copyright (c)  Gjero Krsteski (http://krsteski.de)
6
 * @license   http://opensource.org/licenses/MIT MIT License
7
 */
8
9
namespace Pimf\Session\Storages;
10
11
use Pimf\Util\Character;
12
13
/**
14
 * @package Session_Storages
15
 * @author  Gjero Krsteski <[email protected]>
16
 */
17
abstract class Storage
18
{
19
    /**
20
     * Load a session from storage by a given ID.
21
     * If no session is found for the id, null will be returned.
22
     *
23
     * @param string $key
24
     *
25
     * @return array|null
26
     */
27
    abstract public function load($key);
28
29
    /**
30
     * Save a given session to storage.
31
     *
32
     * @param array $session
33
     * @param array $config
34
     * @param bool  $exists
35
     *
36
     * @return void
37
     */
38
    abstract public function save($session, $config, $exists);
39
40
    /**
41
     * Delete a session from storage by a given ID.
42
     *
43
     * @param string $key
44
     *
45
     * @return void
46
     */
47
    abstract public function delete($key);
48
49
    /**
50
     * Create a fresh session array with a unique ID.
51
     *
52
     * @return array
53
     */
54
    public function fresh()
55
    {
56
        return array('id' => $this->id(), 'data' => array(':new:' => array(), ':old:' => array(),));
57
    }
58
59
    /**
60
     * Get a new session ID that isn't assigned to any current session.
61
     *
62
     * @return string
63
     */
64
    public function id()
65
    {
66
        // just return any string since the Cookie storage has no idea.
67
        if ($this instanceof \Pimf\Session\Storages\Cookie) {
68
            return Character::random(40);
69
        }
70
71
        // we'll find an random ID here.
72
        do {
73
            $session = $this->load($key = Character::random(40));
74
        } while ($session !== null);
75
76
        return $key;
77
    }
78
}
79