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 ( 2a6107...213cde )
by Vermeulen
01:45
created

ModuleInstall::run()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace BFW\Install\Core\AppSystems;
4
5
use \BFW\Core\AppSystems\AbstractSystem;
6
use \BFW\Helpers\Cli;
7
8
class ModuleInstall extends AbstractSystem
9
{
10
    /**
11
     * @var \BFW\Install\ModuleInstall[] $listToInstall
12
     */
13
    protected $listToInstall = [];
14
    
15
    /**
16
     * {@inheritdoc}
17
     * 
18
     * @return $this
19
     */
20
    public function __invoke()
21
    {
22
        return $this;
23
    }
24
    
25
    /**
26
     * Getter accessor to property listToInstall
27
     * 
28
     * @return \BFW\Install\ModuleInstall[]
29
     */
30
    public function getListToInstall(): array
31
    {
32
        return $this->listToInstall;
33
    }
34
    
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function init()
39
    {
40
        $this->initStatus = true;
41
    }
42
    
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function toRun(): bool
47
    {
48
        return true;
49
    }
50
    
51
    /**
52
     * {@inheritdoc}
53
     * Run install of all modules
54
     */
55
    public function run()
56
    {
57
        $this->installAllModules();
58
        $this->runStatus = true;
59
    }
60
    
61
    /**
62
     * Add a new module to the list to install
63
     * 
64
     * @param \BFW\Install\ModuleInstall $module The new module
65
     * 
66
     * @return $this
67
     */
68
    public function addToList(\BFW\Install\ModuleInstall $module): self
69
    {
70
        $moduleName = $module->getName();
71
        
72
        $this->listToInstall[$moduleName] = $module;
73
        
74
        return $this;
75
    }
76
    
77
    /**
78
     * Install all modules in the order of the dependency tree.
79
     * 
80
     * @return void
81
     */
82
    protected function installAllModules()
83
    {
84
        Cli::displayMsgNL('Read all modules to run install script...');
85
        
86
        $tree = \BFW\Install\Application::getInstance()
87
            ->getModuleList()
88
            ->getLoadTree()
89
        ;
90
91
        foreach ($tree as $firstLine) {
92
            foreach ($firstLine as $secondLine) {
93
                foreach ($secondLine as $moduleName) {
94
                    if (!isset($this->listToInstall[$moduleName])) {
95
                        continue;
96
                    }
97
                    
98
                    $this->installModule($moduleName);
99
                }
100
            }
101
        }
102
        
103
        Cli::displayMsgNL('All modules have been read.');
104
    }
105
    
106
    /**
107
     * Install a module
108
     * 
109
     * @param string $moduleName The module name
110
     * 
111
     * @return void
112
     */
113
    protected function installModule(string $moduleName)
114
    {
115
        if (!isset($this->listToInstall[$moduleName])) {
116
            return;
117
        }
118
        
119
        Cli::displayMsgNL(' > Read for module '.$moduleName);
120
        
121
        $module         = $this->listToInstall[$moduleName];
122
        $installScripts = $module->getSourceInstallScript();
123
        
124
        if (empty($installScripts) || $installScripts === false) {
125
            Cli::displayMsgNL(' >> No script to run.');
126
            return;
127
        }
128
        
129
        if (!is_array($installScripts)) {
130
            $installScripts = [$installScripts];
131
        }
132
        
133
        foreach ($installScripts as $scriptPath) {
134
            $module->runInstallScript($scriptPath);
135
        }
136
    }
137
}
138