Reorganise::runActualTask()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 10
c 0
b 0
f 0
dl 0
loc 14
rs 9.9332
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
 * Runs the silverstripe/upgrade task "reorganise". See:
9
 * https://github.com/silverstripe/silverstripe-upgrader#reorganise
10
 * You can use this command to reorganise your folder structure to
11
 * conform to the new structure introduced with SilverStripe 4.1.
12
 * Your mysite folder will be renamed to app and your code folder will be rename to src.
13
 */
14
class Reorganise extends Task
15
{
16
    protected $taskStep = 's50';
17
18
    protected $param1 = '';
19
20
    protected $param2 = '';
21
22
    protected $rootDirForCommand = '';
23
24
    protected $settings = '';
25
26
    public function getTitle()
27
    {
28
        return 'move mysite/code folder to app/src';
29
    }
30
31
    public function getDescription()
32
    {
33
        return '
34
            Runs the silverstripe/upgrade task "reorganise". See:
35
            https://github.com/silverstripe/silverstripe-upgrader#reorganise
36
            You can use this command to reorganise your folder structure to
37
            conform to the new structure introduced with SilverStripe 4.1.
38
            Your mysite folder will be renamed to app and your code folder will be renamed to src.
39
            ';
40
    }
41
42
    public function runActualTask($params = []): ?string
43
    {
44
        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

44
        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

44
        if ($this->mu()->/** @scrutinizer ignore-call */ getIsModuleUpgrade()) {
Loading history...
45
        } else {
46
            $this->runSilverstripeUpgradeTask(
47
                'reorganise',
48
                $this->param1,
49
                $this->param2,
50
                $this->rootDirForCommand,
51
                $this->settings
52
            );
53
            $this->setCommitMessage('API:  re-organising files');
54
        }
55
        return null;
56
    }
57
58
    protected function hasCommitAndPush()
59
    {
60
        if ($this->mu()->getIsModuleUpgrade()) {
61
            return false;
62
        }
63
64
        return true;
65
    }
66
}
67