FindYmlExamplesFilesAndChangeExtension   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getTitle() 0 3 1
A getDescription() 0 3 1
A runActualTask() 0 8 1
A hasCommitAndPush() 0 3 1
1
<?php
2
3
namespace Sunnysideup\UpgradeToSilverstripe4\Tasks\IndividualTasks;
4
5
use Sunnysideup\UpgradeToSilverstripe4\Api\FindFiles;
6
use Sunnysideup\UpgradeToSilverstripe4\Tasks\Task;
7
8
/**
9
 * Run a dev/build as a smoke test to see if all is well
10
 */
11
class FindYmlExamplesFilesAndChangeExtension extends Task
12
{
13
    protected $taskStep = 's30';
14
15
    protected $extensions = [
16
        'example',
17
        'Example',
18
        'EXAMPLE',
19
    ];
20
21
    public function getTitle()
22
    {
23
        return 'Find YML extension files and change extension temporarily.';
24
    }
25
26
    public function getDescription()
27
    {
28
        return 'In our modules we include a lot of .yml.example files - we want to update those as well.';
29
    }
30
31
    public function runActualTask($params = []): ?string
32
    {
33
        $files = FindFiles::inst()
34
            ->setSearchPath($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

34
            ->setSearchPath($this->mu()->/** @scrutinizer ignore-call */ getGitRootDir())
Loading history...
35
            ->setExtensions($this->extensions)
36
            ->getFlatFileArray();
37
        print_r($files);
38
        return null;
39
    }
40
41
    protected function hasCommitAndPush()
42
    {
43
        return true;
44
    }
45
}
46