AddUpgradeStarterBranch   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 12
c 1
b 0
f 0
dl 0
loc 35
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getDescription() 0 5 1
A getTitle() 0 3 1
A hasCommitAndPush() 0 3 1
A runActualTask() 0 8 1
1
<?php
2
3
namespace Sunnysideup\UpgradeToSilverstripe4\Tasks\IndividualTasks;
4
5
use Sunnysideup\UpgradeToSilverstripe4\Tasks\Helpers\Git;
6
use Sunnysideup\UpgradeToSilverstripe4\Tasks\Task;
7
8
/**
9
 * This task adds a legacy branch to the git repo of the original to act as a backup/legacy version for
10
 * holding a version of the module before it was changed
11
 */
12
class AddUpgradeStarterBranch extends Task
13
{
14
    protected $taskStep = 's10';
15
16
    public function getTitle()
17
    {
18
        return 'Creates a start branch for upgrading';
19
    }
20
21
    public function getDescription()
22
    {
23
        return '
24
            Creates a starter branch: "' . $this->mu()->getNameOfUpgradeStarterBranch() . '" of your module/app
0 ignored issues
show
Bug introduced by
The method getNameOfUpgradeStarterBranch() 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

24
            Creates a starter branch: "' . $this->mu()->/** @scrutinizer ignore-call */ getNameOfUpgradeStarterBranch() . '" of your module/app
Loading history...
Bug introduced by
It seems like getNameOfUpgradeStarterBranch() 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

24
            Creates a starter branch: "' . $this->mu()->/** @scrutinizer ignore-call */ getNameOfUpgradeStarterBranch() . '" of your module/app
Loading history...
25
            from the "' . $this->mu()->getNameOfBranchForBaseCode() . '" branch.
0 ignored issues
show
Bug introduced by
The method getNameOfBranchForBaseCode() 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

25
            from the "' . $this->mu()->/** @scrutinizer ignore-call */ getNameOfBranchForBaseCode() . '" branch.
Loading history...
Bug introduced by
It seems like getNameOfBranchForBaseCode() 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

25
            from the "' . $this->mu()->/** @scrutinizer ignore-call */ getNameOfBranchForBaseCode() . '" branch.
Loading history...
26
            If it does not exist.
27
            These branch names can be customised with setNameOfUpgradeStarterBranch and setNameOfBranchForBaseCode.
28
            ';
29
    }
30
31
    /**
32
     * @param  array  $params not currently used for this task
33
     */
34
    public function runActualTask($params = []): ?string
35
    {
36
        Git::inst($this->mu())->createNewBranchIfItDoesNotExist(
37
            $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

37
            $this->mu()->/** @scrutinizer ignore-call */ getGitRootDir(),
Loading history...
38
            $this->mu()->getNameOfUpgradeStarterBranch(),
39
            $this->mu()->getNameOfBranchForBaseCode()
40
        );
41
        return null;
42
    }
43
44
    protected function hasCommitAndPush()
45
    {
46
        return false;
47
    }
48
}
49