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.
Completed
Push — 3.0 ( ba3e89...5b4d5c )
by Vermeulen
02:58
created

ReadDirectory::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 2
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 4
rs 10
1
<?php
2
3
namespace BFW\Install;
4
5
class ReadDirectory
6
{
7
    /**
8
     * @var string $calledClass : Name of the current class.
9
     * For recall this correct class when she's extended.
10
     */
11
    protected $calledClass = '';
12
    
13
    /**
14
     * @var array $list : List all path found
15
     */
16
    protected $list;
17
18
    /**
19
     * @var array $ignore : Item to ignored during the reading of directories
20
     */
21
    private $ignore = ['.', '..'];
22
23
    /*
24
     * Constructeur
25
     * 
26
     * @param array &$listFiles : List of file found
27
     */
28
    public function __construct(&$listFiles)
29
    {
30
        $this->calledClass = get_called_class();
31
        $this->list        = &$listFiles;
32
    }
33
34
    /**
35
     * Read all the directories
36
     *
37
     * @param string $path : Path to read
38
     */
39
    public function run($path)
40
    {
41
        $dir = opendir($path);
42
        if ($dir === false) {
43
            return;
44
        }
45
46
        //Tant qu'il y a des fichiers à lire dans le dossier
47
        while (($file = readdir($dir)) !== false) {
48
            $action = $this->fileAction($file, $dir);
0 ignored issues
show
Documentation introduced by
$dir is of type resource, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
49
50
            if ($action === 'continue') {
51
                continue;
52
            } elseif ($action === 'break') {
53
                break;
54
            }
55
            
56
            //If it's a directory
57
            if (is_dir($dir.'/'.$file)) {
58
                $this->dirAction($dir.'/'.$file);
0 ignored issues
show
Documentation introduced by
$dir . '/' . $file is of type string, but the function expects a object<BFW\Install\type>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
59
                continue;
60
            }
61
        }
62
63
        closedir($dir);
64
    }
65
66
    /**
67
     * Action to do when a file is found.
68
     * 
69
     * @param string $fileName Name of the file
70
     * @param string $pathToFile Path of the file
71
     * 
72
     * @return string
73
     */
74
    protected function fileAction($fileName, $pathToFile)
75
    {
76
        if (in_array($fileName, $this->ignore)) {
77
            return 'continue';
78
        }
79
    }
80
    
81
    /**
82
     * Recall ReadDirectory to read this directory
83
     * This is to avoid having the recursion error
84
     * 
85
     * @param type $directory
86
     */
87
    protected function dirAction($directory)
88
    {
89
        $read = new $this->calledClass($this->list);
90
        $read->run($directory);
91
    }
92
}
93