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.

File::save()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 3
dl 0
loc 4
rs 10
c 0
b 0
f 0
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\Contracts\Cleanable;
12
13
/**
14
 * @package Session_Storages
15
 * @author  Gjero Krsteski <[email protected]>
16
 */
17
class File extends Storage implements Cleanable
18
{
19
    /**
20
     * The path to which the session files should be written.
21
     *
22
     * @var string
23
     */
24
    private $path;
25
26
    /**
27
     * @param string $path
28
     */
29
    public function __construct($path)
30
    {
31
        $this->path = (string)$path;
32
    }
33
34
    /**
35
     * Load a session from storage by a given ID.
36
     *
37
     * @param string $key
38
     *
39
     * @return array|mixed|null
40
     */
41
    public function load($key)
42
    {
43
        if (file_exists($path = $this->path . $key)) {
44
            return unserialize(file_get_contents($path));
45
        }
46
47
        return null;
48
    }
49
50
    /**
51
     * Save a given session to storage.
52
     *
53
     * @param array $session
54
     * @param array $config
55
     * @param bool  $exists
56
     */
57
    public function save($session, $config, $exists)
58
    {
59
        file_put_contents($this->path . $session['id'], serialize($session), LOCK_EX);
60
    }
61
62
    /**
63
     * @param string $key
64
     */
65
    public function delete($key)
66
    {
67
        if (file_exists($this->path . $key)) {
68
            unlink($this->path . $key);
69
        }
70
    }
71
72
    /**
73
     * Delete all expired sessions from persistent storage.
74
     *
75
     * @param int $expiration
76
     *
77
     * @return mixed|void
78
     */
79
    public function clean($expiration)
80
    {
81
        $files = glob($this->path . '*');
82
83
        if ($files === false) {
84
            return;
85
        }
86
87
        foreach ($files as $file) {
88
            if (filetype($file) == 'file' && filemtime($file) < $expiration) {
89
                unlink($file);
90
            }
91
        }
92
    }
93
}
94