ResetWebRootDir   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 10
c 1
b 0
f 0
dl 0
loc 27
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 7 1
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
 * Delete the web root directory to allow for a fresh install.
10
 */
11
class ResetWebRootDir extends Task
12
{
13
    protected $taskStep = 's00';
14
15
    public function getTitle()
16
    {
17
        return 'Remove and reset the web root';
18
    }
19
20
    public function getDescription()
21
    {
22
        return '
23
            Delete the web root directory to allow for a fresh install.';
24
    }
25
26
    public function runActualTask($params = []): ?string
27
    {
28
        FileSystemFixes::inst($this->mu())
29
            ->removeDirOrFile($this->mu()->getWebRootDirLocation(), $this->mu()->getAboveWebRootDirLocation());
0 ignored issues
show
Bug introduced by
It seems like getAboveWebRootDirLocation() 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

29
            ->removeDirOrFile($this->mu()->getWebRootDirLocation(), $this->mu()->/** @scrutinizer ignore-call */ getAboveWebRootDirLocation());
Loading history...
Bug introduced by
The method getAboveWebRootDirLocation() 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

29
            ->removeDirOrFile($this->mu()->getWebRootDirLocation(), $this->mu()->/** @scrutinizer ignore-call */ getAboveWebRootDirLocation());
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

29
            ->removeDirOrFile($this->mu()->/** @scrutinizer ignore-call */ getWebRootDirLocation(), $this->mu()->getAboveWebRootDirLocation());
Loading history...
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

29
            ->removeDirOrFile($this->mu()->/** @scrutinizer ignore-call */ getWebRootDirLocation(), $this->mu()->getAboveWebRootDirLocation());
Loading history...
30
        FileSystemFixes::inst($this->mu())
31
            ->mkDir($this->mu()->getWebRootDirLocation(), $this->mu()->getAboveWebRootDirLocation());
32
        return null;
33
    }
34
35
    protected function hasCommitAndPush()
36
    {
37
        return false;
38
    }
39
}
40