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.
Passed
Branch 3.0 (cbdaa6)
by Vermeulen
04:11
created

ModuleInfo::__construct()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 5
nc 3
nop 1
dl 0
loc 11
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace BFW\Install\ModuleManager;
4
5
class ModuleInfo
6
{
7
    /**
8
     * Info extracted from file bfwModulesInfos.json (json_decode)
9
     *
10
     * @var array|object
11
     */
12
    protected $info;
13
14
    /**
15
     * The src path into the module.
16
     *
17
     * @var string
18
     */
19
    protected $srcPath = '';
20
21
    /**
22
     * The list of all config files declared.
23
     * If the value in $info is not an array, it will be converted.
24
     *
25
     * @var array
26
     */
27
    protected $configFiles = [];
28
29
    /**
30
     * The path to config files
31
     *
32
     * @var string
33
     */
34
    protected $configPath = '';
35
36
    /**
37
     * The path to the install script.
38
     * If the value in $info is not a string, it will be converted.
39
     *
40
     * @var string
41
     */
42
    protected $installScript = '';
43
    
44
    /**
45
     * Constructor
46
     *
47
     * Read all properties in $moduleInfo and populate class properties with it.
48
     * If a property is in $moduleInfo but not exist in the class, it will be
49
     * create "on the fly", so it will be public.
50
     * After that, call the method to convert somes values.
51
     *
52
     * @param array|object $moduleInfo
53
     */
54
    public function __construct($moduleInfo)
55
    {
56
        $this->info = $moduleInfo;
57
58
        foreach ($this as $propName => $propDefaultValue) {
59
            if (property_exists($moduleInfo, $propName)) {
60
                $this->{$propName} = $moduleInfo->{$propName};
61
            }
62
        }
63
        
64
        $this->convertValues();
65
    }
66
67
    /**
68
     * Get the value of info (return of json_decode)
69
     *
70
     * @return array|object
71
     */
72
    public function getInfo()
73
    {
74
        return $this->info;
75
    }
76
77
    /**
78
     * Get the value of srcPath
79
     *
80
     * @return string
81
     */
82
    public function getSrcPath(): string
83
    {
84
        return $this->srcPath;
85
    }
86
87
    /**
88
     * Get the value of configFiles
89
     *
90
     * @return array
91
     */
92
    public function getConfigFiles(): array
93
    {
94
        return $this->configFiles;
95
    }
96
97
    /**
98
     * Get the value of configPath
99
     *
100
     * @return string
101
     */
102
    public function getConfigPath(): string
103
    {
104
        return $this->configPath;
105
    }
106
107
    /**
108
     * Get the value of installScript
109
     *
110
     * @return string
111
     */
112
    public function getInstallScript(): string
113
    {
114
        return $this->installScript;
115
    }
116
    
117
    /**
118
     * Call methods to convert values for some properties
119
     *
120
     * @return void
121
     */
122
    protected function convertValues()
123
    {
124
        $this->convertConfigFiles();
125
        $this->convertInstallScript();
126
    }
127
128
    /**
129
     * Convert the value of $configFiles
130
     *
131
     * @return void
132
     */
133
    protected function convertConfigFiles()
134
    {
135
        if (is_array($this->configFiles)) {
0 ignored issues
show
introduced by
The condition is_array($this->configFiles) is always true.
Loading history...
136
            return;
137
        }
138
139
        if (is_string($this->configFiles) === false) {
140
            $this->configFiles = [];
141
        } else {
142
            $this->configFiles = (array) $this->configFiles;
143
        }
144
    }
145
146
    /**
147
     * Convert the value of $installScript
148
     *
149
     * @return void
150
     */
151
    protected function convertInstallScript()
152
    {
153
        if ($this->installScript === true) {
0 ignored issues
show
introduced by
The condition $this->installScript === true is always false.
Loading history...
154
            $this->installScript = 'runInstallModule.php';
155
        }
156
157
        if (is_string($this->installScript) === false) {
0 ignored issues
show
introduced by
The condition is_string($this->installScript) === false is always false.
Loading history...
158
            $this->installScript = '';
159
        }
160
    }
161
}
162