DeleteDir::run()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 11

Duplication

Lines 11
Ratio 100 %

Importance

Changes 0
Metric Value
dl 11
loc 11
rs 9.9
c 0
b 0
f 0
cc 3
nc 3
nop 0
1
<?php
2
3
namespace Robo\Task\Filesystem;
4
5
use Robo\Common\ResourceExistenceChecker;
6
use Robo\Result;
7
8
/**
9
 * Deletes dir
10
 *
11
 * ``` php
12
 * <?php
13
 * $this->taskDeleteDir('tmp')->run();
14
 * // as shortcut
15
 * $this->_deleteDir(['tmp', 'log']);
16
 * ?>
17
 * ```
18
 */
19
class DeleteDir extends BaseDir
20
{
21
    use ResourceExistenceChecker;
22
23
    /**
24
     * {@inheritdoc}
25
     */
26 View Code Duplication
    public function run()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
27
    {
28
        if (!$this->checkResources($this->dirs, 'dir')) {
29
            return Result::error($this, 'Source directories are missing!');
30
        }
31
        foreach ($this->dirs as $dir) {
32
            $this->fs->remove($dir);
33
            $this->printTaskInfo("Deleted {dir}...", ['dir' => $dir]);
34
        }
35
        return Result::success($this);
36
    }
37
}
38