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

runActualTask()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 14
rs 9.9
cc 2
nc 2
nop 1
1
<?php
2
3
namespace Sunnysideup\UpgradeToSilverstripe4\Tasks\IndividualTasks;
4
5
use Sunnysideup\UpgradeToSilverstripe4\Tasks\Task;
6
7
/**
8
 * Replaces the composer type from silverstripe-module to silverstripe-vendormodule in line with SS4 standards.
9
 * This means your module will be installed in the vendor folder after this upgrade.
10
 */
11
class AddLicenceToProjectForRecomposeTask extends Task
12
{
13
    protected $taskStep = 's50';
14
15
    public function getTitle()
16
    {
17
        return 'Add license to project to ensure recompose works.';
18
    }
19
20
    public function getDescription()
21
    {
22
        return '
23
            Adds the license = proprietary to the composer file to ensure the recompose task works.';
24
    }
25
26
    public function runActualTask($params = [])
27
    {
28
        if ($this->mu()->getIsProjectUpgrade()) {
29
            $comment = 'add license';
30
            $command =
31
            'if(! isset($data["license"])) { '
32
            . '    $data["license"] = proprietary";'
33
            . '}';
34
            $this->updateJSONViaCommandLine(
35
                $this->mu()->getGitRootDir(),
36
                $command,
37
                $comment
38
            );
39
            $this->setCommitMessage('MAJOR: ' . $this->getTitle());
40
        }
41
    }
42
43
    protected function hasCommitAndPush()
44
    {
45
        return $this->mu()->getIsModuleUpgrade() ? false : true;
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

45
        return $this->mu()->/** @scrutinizer ignore-call */ getIsModuleUpgrade() ? false : true;
Loading history...
46
    }
47
}
48