Upgrade   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Importance

Changes 4
Bugs 3 Features 0
Metric Value
wmc 5
eloc 22
c 4
b 3
f 0
dl 0
loc 51
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getTitle() 0 3 1
A getDescription() 0 3 1
A runActualTask() 0 17 2
A hasCommitAndPush() 0 3 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 'upgrade'.
9
 * More information on this task at https://github.com/silverstripe/silverstripe-upgrader#upgrade
10
 */
11
class Upgrade extends Task
12
{
13
    protected $taskStep = 's40';
14
15
    protected $param1 = '';
16
17
    protected $param2 = '';
18
19
    protected $rootDirForCommand = '';
20
21
    /**
22
     * @todo Prompt does not show up sometimes, leaving the program hanging
23
     * --prompt
24
     */
25
    protected $settings = '';
26
27
    public function getTitle()
28
    {
29
        return 'Update Code';
30
    }
31
32
    public function getDescription()
33
    {
34
        return '
35
            Runs the silverstripe/upgrade task "upgrade". See:
36
            Upgrade a variety of stuff (e.g. update reference with namespaces)
37
            https://github.com/silverstripe/silverstripe-upgrader#upgrade';
38
    }
39
40
    public function runActualTask($params = []): ?string
41
    {
42
        $this->mu()->setBreakOnAllErrors(true);
0 ignored issues
show
Bug introduced by
It seems like setBreakOnAllErrors() 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

42
        $this->mu()->/** @scrutinizer ignore-call */ setBreakOnAllErrors(true);
Loading history...
43
        foreach ($this->mu()->findNameSpaceAndCodeDirs() as $codeDir) {
0 ignored issues
show
Bug introduced by
It seems like findNameSpaceAndCodeDirs() 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
        foreach ($this->mu()->/** @scrutinizer ignore-call */ findNameSpaceAndCodeDirs() as $codeDir) {
Loading history...
44
            $actualDir = dirname($codeDir);
45
            $this->param1 = $actualDir;
46
            $this->runSilverstripeUpgradeTask(
47
                'upgrade',
48
                $this->param1,
49
                $this->param2,
50
                $this->rootDirForCommand,
51
                $this->settings
52
            );
53
            $this->setCommitMessage('API:  core upgrade to SS4 - STEP 1 (upgrade) on ' . $actualDir);
54
        }
55
        $this->mu()->setBreakOnAllErrors(false);
56
        return null;
57
    }
58
59
    protected function hasCommitAndPush()
60
    {
61
        return true;
62
    }
63
}
64