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 ( f6700a...4f8385 )
by Vermeulen
02:14
created

Application   A

Complexity

Total Complexity 18

Size/Duplication

Total Lines 111
Duplicated Lines 13.51 %

Coupling/Cohesion

Components 2
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 18
c 1
b 0
f 0
lcom 2
cbo 3
dl 15
loc 111
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A initRequest() 0 4 1
A initSession() 0 4 1
A initErrors() 0 4 1
A addModuleInstallInstance() 0 7 1
A declareRunPhases() 0 8 1
A run() 15 15 3
B installModules() 0 18 5
B installModule() 0 24 5

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace BFW\Install;
4
5
/**
6
 * Application class for install module script
7
 */
8
class Application extends \BFW\Application
9
{
10
    protected static $modulesInstances = [];
11
    
12
    /**
13
     * {@inheritdoc}
14
     */
15
    protected function initRequest()
16
    {
17
        return;
18
    }
19
20
    /**
21
     * {@inheritdoc}
22
     */
23
    protected function initSession()
24
    {
25
        return;
26
    }
27
28
    /**
29
     * {@inheritdoc}
30
     */
31
    protected function initErrors()
32
    {
33
        return;
34
    }
35
    
36
    public static function addModuleInstallInstance(
37
        \BFW\Install\ModuleInstall $module
38
    ) {
39
        $moduleName = $module->getName();
40
        
41
        self::$modulesInstances[$moduleName] = $module;
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47
    protected function declareRunPhases()
48
    {
49
        $this->runPhases = [
50
            [$this, 'loadMemcached'],
51
            [$this, 'readAllModules'],
52
            [$this, 'installModules']
53
        ];
54
    }
55
56
    /**
57
     * {@inheritdoc}
58
     */
59 View Code Duplication
    public function run()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
60
    {
61
        foreach ($this->runPhases as $action) {
62
            $action();
63
64
            $notifyAction = $action;
65
            if (is_array($action)) {
66
                $notifyAction = $action[1];
67
            }
68
69
            $this->notifyAction('bfw_modules_install_run_'.$notifyAction);
70
        }
71
72
        $this->notifyAction('bfw_modules_install_finish');
73
    }
74
    
75
    protected function installModules()
76
    {
77
        echo 'Read all modules to run install script :'."\n";
78
        
79
        $tree = $this->modules->getLoadTree();
80
81
        foreach ($tree as $firstLine) {
82
            foreach ($firstLine as $secondLine) {
83
                foreach ($secondLine as $moduleName) {
84
                    if (!isset(self::$modulesInstances[$moduleName])) {
85
                        continue;
86
                    }
87
                    
88
                    $this->installModule($moduleName);
89
                }
90
            }
91
        }
92
    }
93
    
94
    protected function installModule($moduleName)
95
    {
96
        if (!isset(self::$modulesInstances[$moduleName])) {
97
            return;
98
        }
99
        
100
        echo ' > Read for module '.$moduleName."\n";
101
        
102
        $module         = self::$modulesInstances[$moduleName];
103
        $installScripts = $module->getSourceInstallScript();
104
        
105
        if ($installScripts === '') {
106
            echo ' >> No script to run.'."\n";
107
            return;
108
        }
109
        
110
        if (is_string($installScripts)) {
111
            $installScripts = (array) $installScripts;
112
        }
113
        
114
        foreach ($installScripts as $scriptPath) {
115
            $module->runInstall($scriptPath);
116
        }
117
    }
118
}
119