AddLegacyBranch   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getTitle() 0 3 1
A getDescription() 0 5 1
A runActualTask() 0 9 1
A hasCommitAndPush() 0 3 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 AddLegacyBranch extends Task
13
{
14
    protected $taskStep = 's10';
15
16
    /**
17
     * @var string what should the legacy branch be called
18
     */
19
    protected $nameOfLegacyBranch = '3';
20
21
    public function getTitle()
22
    {
23
        return 'Add Legacy Branch';
24
    }
25
26
    public function getDescription()
27
    {
28
        return '
29
            Creates a legacy branch: "' . $this->nameOfLegacyBranch . '" of your module
30
            from the "' . $this->mu()->getNameOfBranchForBaseCode() . '" branch so that you
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

30
            from the "' . $this->mu()->/** @scrutinizer ignore-call */ getNameOfBranchForBaseCode() . '" branch so that you
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

30
            from the "' . $this->mu()->/** @scrutinizer ignore-call */ getNameOfBranchForBaseCode() . '" branch so that you
Loading history...
31
            can keep making bugfixes to older versions.
32
            In the recipes you can see how to set the name of the legacy branch.';
33
    }
34
35
    /**
36
     * @param  array  $params not currently used for this task
37
     */
38
    public function runActualTask($params = []): ?string
39
    {
40
        $gitRootDir = $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

40
        $gitRootDir = $this->mu()->/** @scrutinizer ignore-call */ getGitRootDir();
Loading history...
41
        Git::inst($this->mu())->createNewBranchIfItDoesNotExist(
42
            $gitRootDir,
43
            $this->nameOfLegacyBranch,
44
            $this->mu()->getNameOfBranchForBaseCode()
45
        );
46
        return null;
47
    }
48
49
    protected function hasCommitAndPush()
50
    {
51
        return false;
52
    }
53
}
54