CreatePublicFolder   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getTitle() 0 3 1
A getDescription() 0 4 1
A hasCommitAndPush() 0 3 1
A runActualTask() 0 15 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 CreatePublicFolder extends Task
13
{
14
    protected $taskStep = 's10';
15
16
    protected $publicFolderName = 'public';
17
18
    public function getTitle()
19
    {
20
        return 'Create a public folder to match SS4 folder structure';
21
    }
22
23
    public function getDescription()
24
    {
25
        return '
26
            For projects only, we create a public folder: ' . $this->mu()->getWebRootDirLocation() . '/public';
0 ignored issues
show
Bug introduced by
It seems like getWebRootDirLocation() 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
            For projects only, we create a public folder: ' . $this->mu()->/** @scrutinizer ignore-call */ getWebRootDirLocation() . '/public';
Loading history...
Bug introduced by
The method getWebRootDirLocation() 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
            For projects only, we create a public folder: ' . $this->mu()->/** @scrutinizer ignore-call */ getWebRootDirLocation() . '/public';
Loading history...
27
    }
28
29
    /**
30
     * [runActualTask description]
31
     * @param  array  $params not currently used for this task
32
     */
33
    public function runActualTask($params = []): ?string
34
    {
35
        if ($this->mu()->getIsProjectUpgrade()) {
0 ignored issues
show
Bug introduced by
It seems like getIsProjectUpgrade() 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
        if ($this->mu()->/** @scrutinizer ignore-call */ getIsProjectUpgrade()) {
Loading history...
36
            $newFolder = $this->mu()->getWebRootDirLocation() . '/' . $this->publicFolderName;
37
            FileSystemFixes::inst($this->mu())
38
                ->mkDir($newFolder);
39
40
            $this->mu()->execMe(
0 ignored issues
show
Bug introduced by
It seems like execMe() 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
            $this->mu()->/** @scrutinizer ignore-call */ execMe(
Loading history...
41
                $newFolder,
42
                'echo \'hello world\' >> hello-world.html',
43
                'adding public test file',
44
                false
45
            );
46
        }
47
        return null;
48
    }
49
50
    protected function hasCommitAndPush()
51
    {
52
        return $this->mu()->getIsProjectUpgrade();
53
    }
54
}
55