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.

FileModifiedChecker::__invoke()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3.0416

Importance

Changes 0
Metric Value
cc 3
nc 3
nop 2
dl 0
loc 8
ccs 5
cts 6
cp 0.8333
crap 3.0416
rs 10
c 0
b 0
f 0
1
<?php
2
namespace PhpBoot\Cache;
3
4
/**
5
 * 检查文件是否过期
6
 * @author caoym
7
 */
8
class FileModifiedChecker
9
{
10
    /**
11
     * @param string|array $fileName 文件的绝对路径
12
     */
13 21
    function __construct($fileName){
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...
14 21
        $fileNames = array();
15 21
        if(is_string($fileName)){
16
            $fileNames[]=$fileName;
17
        }else{
18 21
            is_array($fileName) or \PhpBoot\abort(new \InvalidArgumentException("string or array is required by param 0"));
19 21
            $fileNames = $fileName;
20
        }
21 21
        foreach ($fileNames as $fileName){
22 21
            if(is_file($fileName)){
23 21
                $this->fileName[$fileName] = @filemtime($fileName);
24 21
            }else {
25
                $this->fileName[$fileName] = @filemtime($fileName);
26
                if(!is_dir($fileName)){
27
                    continue;
28
                }
29
                $files = @dir($fileName) or \PhpBoot\abort("open dir $fileName failed");
30
                while (!!($file = $files->read())){
31
                    if($file == '.' || $file == '..') {
32
                        continue;
33
                    }
34
                    $this->fileName[$fileName.'/'.$file] = @filemtime($fileName.'/'.$file);
35
                }
36
                $files->close();
37
            }
38 21
        }
39 21
    }
40
    /**
41
     * 判断是否过期
42
     * @param mixed $data 从缓存中得到的数据
43
     * @param int $createdTime
44
     * @return boolean
45
     */
46 74
    public function __invoke($data, $createdTime){
47 74
        foreach ($this->fileName as $name => $time){
48 74
            if(@filemtime($name) != $time){
49
                return false;
50
            }
51 74
        }
52 74
        return true;
53
    }
54
    private $fileName=[]; //文件全路径
55
}
56