Passed
Push — master ( f01d00...2f7647 )
by Nicolaas
03:27
created

DoctorTask   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 18
c 1
b 0
f 0
dl 0
loc 44
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A hasCommitAndPush() 0 6 2
A getTitle() 0 3 1
A runActualTask() 0 12 2
A getDescription() 0 3 1
1
<?php
2
3
namespace Sunnysideup\UpgradeToSilverstripe4\Tasks\IndividualTasks;
4
5
use Sunnysideup\UpgradeToSilverstripe4\Tasks\Task;
6
7
/**
8
 * Runs the silverstripe/upgrade task "environment". See:
9
 * https://github.com/silverstripe/silverstripe-upgrader#environment.
10
 * You can use this command to migrate an SilverStripe 3 _ss_environment.php
11
 * file to the .env format used by SilverStripe 4.'
12
 */
13
class DoctorTask extends Task
14
{
15
    protected $taskStep = 's30';
16
17
    protected $param1 = '';
18
19
    protected $param2 = '';
20
21
    protected $rootDirForCommand = '';
22
23
    public function getTitle()
24
    {
25
        return 'Fix up .htaccess and index.html';
26
    }
27
28
    public function getDescription()
29
    {
30
        return '
31
            Runs the silverstripe/upgrade task "doctor". See:
32
            https://github.com/silverstripe/silverstripe-upgrader#doctor.
33
            CAREFUL: will remove any customisations!';
34
    }
35
36
    public function runActualTask($params = [])
37
    {
38
        if ($this->mu()->getIsModuleUpgrade()) {
0 ignored issues
show
Bug introduced by
The method getIsModuleUpgrade() does not exist on Sunnysideup\UpgradeToSilverstripe4\ModuleUpgrader. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

38
        if ($this->mu()->/** @scrutinizer ignore-call */ getIsModuleUpgrade()) {
Loading history...
39
            //do nothing ...
40
        } else {
41
            $this->runSilverstripeUpgradeTask(
42
                'doctor',
43
                $this->param1,
44
                $this->param2,
45
                $this->rootDirForCommand
46
            );
47
            $this->setCommitMessage('MAJOR: changing environment file(s)');
48
        }
49
    }
50
51
    protected function hasCommitAndPush()
52
    {
53
        if ($this->mu()->getIsModuleUpgrade()) {
54
            return false;
55
        }
56
        return true;
57
    }
58
}
59