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   A
last analyzed

Complexity

Total Complexity 13

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 55.17%

Importance

Changes 0
Metric Value
dl 0
loc 48
ccs 16
cts 29
cp 0.5517
rs 10
c 0
b 0
f 0
wmc 13
lcom 0
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
B __construct() 0 27 10
A __invoke() 0 8 3
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