MoveCodeToSRC   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 11
c 1
b 0
f 0
dl 0
loc 33
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getDescription() 0 3 1
A getTitle() 0 3 1
A hasCommitAndPush() 0 3 1
A runActualTask() 0 9 2
1
<?php
2
3
namespace Sunnysideup\UpgradeToSilverstripe4\Tasks\IndividualTasks;
4
5
use Sunnysideup\UpgradeToSilverstripe4\Api\FileSystemFixes;
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 MoveCodeToSRC extends Task
13
{
14
    protected $taskStep = 's30';
15
16
    public function getTitle()
17
    {
18
        return 'Move code to src folder';
19
    }
20
21
    public function getDescription()
22
    {
23
        return '
24
            Move the code folder to the src folder to match PSR requirements.';
25
    }
26
27
    /**
28
     * [runActualTask description]
29
     * @param  array  $params not currently used for this task
30
     */
31
    public function runActualTask($params = []): ?string
32
    {
33
        foreach ($this->mu()->getExistingModuleDirLocations() as $moduleDir) {
0 ignored issues
show
Bug introduced by
It seems like getExistingModuleDirLocations() 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

33
        foreach ($this->mu()->/** @scrutinizer ignore-call */ getExistingModuleDirLocations() as $moduleDir) {
Loading history...
34
            $old = '/code/';
35
            $new = '/src/';
36
            $fixer = FileSystemFixes::inst($this->mu());
37
            $fixer->moveFolderOrFile($moduleDir . $old, $moduleDir . $new);
38
        }
39
        return null;
40
    }
41
42
    protected function hasCommitAndPush()
43
    {
44
        return true;
45
    }
46
}
47