Passed
Branch master (2f7647)
by Nicolaas
04:56 queued 03:20
created

ChangeEnvironment::hasCommitAndPush()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
c 0
b 0
f 0
dl 0
loc 6
rs 10
cc 2
nc 2
nop 0
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 = [])
40
    {
41
        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

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('MAJOR: changing environment file(s)');
52
        }
53
    }
54
55
    protected function hasCommitAndPush()
56
    {
57
        if ($this->mu()->getIsModuleUpgrade()) {
58
            return false;
59
        }
60
        return true;
61
    }
62
}
63