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.

FileLock::lock()   A
last analyzed

Complexity

Conditions 5
Paths 6

Size

Total Lines 17

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 30

Importance

Changes 0
Metric Value
cc 5
nc 6
nop 2
dl 0
loc 17
ccs 0
cts 17
cp 0
crap 30
rs 9.3888
c 0
b 0
f 0
1
<?php
2
namespace PhpBoot\Lock;
3
4
use PhpBoot\Utils\SafeFileWriter;
5
6
class FileLock implements LockInterface
7
{
8
    private $file;
9
    public function lock($key, $ttl)
10
    {
11
        if($this->locked){
12
            \PhpBoot\abort("relock $key");
13
        }
14
        $path = sys_get_temp_dir().'/lock_252a8fdc9b944af99a9bc53d2aea08f1_'.$key;
15
        $this->file = @fopen($path, 'a');
16
        if (!$this->file || !flock($this->file, LOCK_EX | LOCK_NB)) {
17
            if($this->file){
18
                fclose($this->file);
19
            }
20
            return false;
21
        } else {
22
            $this->locked = true;
23
        }
24
        return true;
25
    }
26
27
    public function unlock($key)
28
    {
29
        $this->locked or \PhpBoot\abort("unlock unlocked $key");
30
        flock($this->file, LOCK_UN);
31
        fclose($this->file);
32
        $this->file = null;
33
        $this->locked = false;
34
        return true;
35
    }
36
    private $locked = false;
37
}