Passed
Push — master ( f01d00...2f7647 )
by Nicolaas
03:27
created

MoveCodeToSRC   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getDescription() 0 3 1
A hasCommitAndPush() 0 3 1
A getTitle() 0 3 1
A runActualTask() 0 15 2
1
<?php
2
3
namespace Sunnysideup\UpgradeToSilverstripe4\Tasks\IndividualTasks;
4
5
use Sunnysideup\UpgradeToSilverstripe4\Tasks\Task;
6
7
/**
8
 * This task adds a legacy branch to the git repo of the original to act as a backup/legacy version for
9
 * holding a version of the module before it was changed
10
 */
11
class MoveCodeToSRC extends Task
12
{
13
    protected $taskStep = 's30';
14
15
    public function getTitle()
16
    {
17
        return 'Move code to src folder';
18
    }
19
20
    public function getDescription()
21
    {
22
        return '
23
            Move the code folder to the src folder to match PSR requirements.';
24
    }
25
26
    /**
27
     * [runActualTask description]
28
     * @param  array  $params not currently used for this task
29
     * @return [type]         [description]
0 ignored issues
show
Documentation Bug introduced by
The doc comment [type] at position 0 could not be parsed: Unknown type name '[' at position 0 in [type].
Loading history...
30
     */
31
    public function runActualTask($params = [])
32
    {
33
        foreach ($this->mu()->getExistingModuleDirLocations() as $moduleDir) {
34
            $old = './code/';
35
            $new = './src/';
36
            $this->mu()->execMe(
37
                $moduleDir,
38
                '
39
if test -d ' . $old . '; then
40
    mv -vn ' . $old . ' ' . $new . ';
41
else
42
    echo \' !!!!!!!!! Error in moving ' . $moduleDir . '/' . $old . ' to ' . $moduleDir . '/' . $new . ' !!!!!!!!! \';
43
fi;',
44
                'moving ' . $old . ' to ' . $new . ' -v is verbose, -n is only if destination does not exists',
45
                false
46
            );
47
        }
48
    }
49
50
    protected function hasCommitAndPush()
51
    {
52
        return true;
53
    }
54
}
55