Recompose::getDescription()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
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 "recompose". See:
9
 * https://github.com/silverstripe/silverstripe-upgrader#recompose'
10
 */
11
class Recompose extends Task
12
{
13
    protected $taskStep = 's20';
14
15
    protected $param1 = '';
16
17
    protected $param2 = '';
18
19
    protected $rootDirForCommand = '';
20
21
    protected $settings = '';
22
23
    public function getTitle()
24
    {
25
        return 'Update composer.json from 3 to 4';
26
    }
27
28
    public function getDescription()
29
    {
30
        return '
31
            Runs the silverstripe/upgrade task "recompose". See:
32
            https://github.com/silverstripe/silverstripe-upgrader#recompose';
33
    }
34
35
    public function runActualTask($params = []): ?string
36
    {
37
        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

37
        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

37
        if ($this->mu()->/** @scrutinizer ignore-call */ getIsModuleUpgrade()) {
Loading history...
38
        } else {
39
            if (! $this->param1) {
40
                $this->param1 = '--recipe-core-constraint="' . $this->mu()->getFrameworkComposerRestraint() . '"';
0 ignored issues
show
Bug introduced by
The method getFrameworkComposerRestraint() 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

40
                $this->param1 = '--recipe-core-constraint="' . $this->mu()->/** @scrutinizer ignore-call */ getFrameworkComposerRestraint() . '"';
Loading history...
Bug introduced by
It seems like getFrameworkComposerRestraint() 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

40
                $this->param1 = '--recipe-core-constraint="' . $this->mu()->/** @scrutinizer ignore-call */ getFrameworkComposerRestraint() . '"';
Loading history...
41
            }
42
            if (empty($this->rootDirForCommand)) {
43
                $this->rootDirForCommand = $this->mu()->getGitRootDir();
0 ignored issues
show
Bug introduced by
It seems like getGitRootDir() 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

43
                $this->rootDirForCommand = $this->mu()->/** @scrutinizer ignore-call */ getGitRootDir();
Loading history...
44
            }
45
            $this->runSilverstripeUpgradeTask(
46
                'recompose',
47
                $this->param1,
48
                $this->param2,
49
                $this->rootDirForCommand,
50
                $this->settings
51
            );
52
            $this->setCommitMessage('API:  upgrading composer requirements to SS4 - STEP 2');
53
        }
54
        return null;
55
    }
56
57
    protected function hasCommitAndPush()
58
    {
59
        if ($this->mu()->getIsModuleUpgrade()) {
60
            return false;
61
        }
62
        return true;
63
    }
64
}
65