DoctorTask   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getTitle() 0 3 1
A getDescription() 0 3 1
A hasCommitAndPush() 0 6 2
A runActualTask() 0 14 2
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 = []): ?string
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...
Bug introduced by
It seems like getIsModuleUpgrade() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( 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('API:  changing environment file(s)');
48
        }
49
        return null;
50
    }
51
52
    protected function hasCommitAndPush()
53
    {
54
        if ($this->mu()->getIsModuleUpgrade()) {
55
            return false;
56
        }
57
        return true;
58
    }
59
}
60