ChangeEnvironment   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 6
eloc 21
c 0
b 0
f 0
dl 0
loc 49
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getDescription() 0 3 1
A getTitle() 0 3 1
A hasCommitAndPush() 0 6 2
A runActualTask() 0 15 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 ChangeEnvironment extends Task
14
{
15
    protected $taskStep = 's20';
16
17
    protected $rootDirForCommand = '';
18
19
    protected $param1 = '';
20
21
    protected $param2 = '';
22
23
    protected $settings = '';
24
25
    public function getTitle()
26
    {
27
        return 'Change Environment File';
28
    }
29
30
    public function getDescription()
31
    {
32
        return '
33
            Runs the silverstripe/upgrade task "environment". See:
34
            https://github.com/silverstripe/silverstripe-upgrader#environment.
35
            You can use this command to migrate a SilverStripe 3 _ss_environment.php
36
            file to the Silverstripe 4 .env format.';
37
    }
38
39
    public function runActualTask($params = []): ?string
40
    {
41
        if ($this->mu()->getIsModuleUpgrade()) {
0 ignored issues
show
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

41
        if ($this->mu()->/** @scrutinizer ignore-call */ getIsModuleUpgrade()) {
Loading history...
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

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