Completed
Push — master ( a20e35...2a3e96 )
by Greg
03:21
created

src/Task/Filesystem/DeleteDir.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
namespace Robo\Task\Filesystem;
3
4
use Robo\Common\ResourceExistenceChecker;
5
use Robo\Result;
6
7
/**
8
 * Deletes dir
9
 *
10
 * ``` php
11
 * <?php
12
 * $this->taskDeleteDir('tmp')->run();
13
 * // as shortcut
14
 * $this->_deleteDir(['tmp', 'log']);
15
 * ?>
16
 * ```
17
 */
18
class DeleteDir extends BaseDir
19
{
20
    use ResourceExistenceChecker;
21
22
    /**
23
     * {@inheritdoc}
24
     */
25 View Code Duplication
    public function run()
0 ignored issues
show
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...
26
    {
27
        if (!$this->checkResources($this->dirs, 'dir')) {
28
            return Result::error($this, 'Source directories are missing!');
29
        }
30
        foreach ($this->dirs as $dir) {
31
            $this->fs->remove($dir);
32
            $this->printTaskInfo("Deleted {dir}...", ['dir' => $dir]);
33
        }
34
        return Result::success($this);
35
    }
36
}
37