AddTempUpgradeBranch   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 17
c 1
b 0
f 0
dl 0
loc 38
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getTitle() 0 3 1
A getDescription() 0 7 3
A runActualTask() 0 13 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
 * Adds a new branch to your repository that is going to be used for upgrading it.
10
 */
11
class AddTempUpgradeBranch extends Task
12
{
13
    protected $taskStep = 's10';
14
15
    public function getTitle()
16
    {
17
        return 'Add Upgrade Branch';
18
    }
19
20
    public function getDescription()
21
    {
22
        return '
23
            Adds a new branch ' . $this->mu()->getNameOfTempBranch() . '
0 ignored issues
show
Bug introduced by
It seems like getNameOfTempBranch() 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

23
            Adds a new branch ' . $this->mu()->/** @scrutinizer ignore-call */ getNameOfTempBranch() . '
Loading history...
Bug introduced by
The method getNameOfTempBranch() 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

23
            Adds a new branch ' . $this->mu()->/** @scrutinizer ignore-call */ getNameOfTempBranch() . '
Loading history...
24
            based on ' . $this->mu()->getNameOfUpgradeStarterBranch() . '
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
            based on ' . $this->mu()->/** @scrutinizer ignore-call */ getNameOfUpgradeStarterBranch() . '
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
            based on ' . $this->mu()->/** @scrutinizer ignore-call */ getNameOfUpgradeStarterBranch() . '
Loading history...
25
            (both names can be customised)
26
            to your repository (' . ($this->mu()->getVendorName() ?: 'Vendor Name') . '/' . ($this->mu()->getPackageName() ?: 'Package Name') . ')
0 ignored issues
show
Bug introduced by
The method getVendorName() 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

26
            to your repository (' . ($this->mu()->/** @scrutinizer ignore-call */ getVendorName() ?: 'Vendor Name') . '/' . ($this->mu()->getPackageName() ?: 'Package Name') . ')
Loading history...
Bug introduced by
It seems like getVendorName() 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

26
            to your repository (' . ($this->mu()->/** @scrutinizer ignore-call */ getVendorName() ?: 'Vendor Name') . '/' . ($this->mu()->getPackageName() ?: 'Package Name') . ')
Loading history...
Bug introduced by
It seems like getPackageName() 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

26
            to your repository (' . ($this->mu()->getVendorName() ?: 'Vendor Name') . '/' . ($this->mu()->/** @scrutinizer ignore-call */ getPackageName() ?: 'Package Name') . ')
Loading history...
Bug introduced by
The method getPackageName() 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

26
            to your repository (' . ($this->mu()->getVendorName() ?: 'Vendor Name') . '/' . ($this->mu()->/** @scrutinizer ignore-call */ getPackageName() ?: 'Package Name') . ')
Loading history...
27
            that is going to be used for upgrading it.
28
            If it already exists then it will first be DELETED!';
29
    }
30
31
    public function runActualTask($params = []): ?string
32
    {
33
        Git::inst($this->mu())
34
            ->deleteBranch(
35
                $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

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