Test Failed
Pull Request — master (#448)
by
unknown
05:18
created

RemoveTask   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 3
dl 0
loc 39
ccs 0
cts 28
cp 0
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getDefaults() 0 4 1
A getName() 0 4 1
A getDescription() 0 8 2
A execute() 0 12 1
A getParameters() 0 4 1
1
<?php
2
/*
3
 * This file is part of the Magallanes package.
4
 *
5
 * (c) Andrés Montañez <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Mage\Task\BuiltIn\FS;
12
13
use Symfony\Component\Process\Process;
14
use Exception;
15
16
/**
17
 * File System Task - Remove a File
18
 *
19
 * @author Andrés Montañez <[email protected]>
20
 */
21
class RemoveTask extends AbstractFileTask
22
{
23
    public function getName()
24
    {
25
        return 'fs/remove';
26
    }
27
28
    public function getDescription()
29
    {
30
        try {
31
            return sprintf('[FS] Remove "%s"', $this->getFile('file'));
32
        } catch (Exception $exception) {
33
            return '[FS] Remove [missing parameters]';
34
        }
35
    }
36
37
    public function execute()
38
    {
39
        $file = $this->getFile('file');
40
        $flags = $this->options['flags'];
41
42
        $cmd = sprintf('rm %s "%s"', $flags, $file);
43
44
        /** @var Process $process */
45
        $process = $this->runtime->runCommand($cmd);
46
47
        return $process->isSuccessful();
48
    }
49
50
    protected function getParameters()
51
    {
52
        return ['file', 'flags'];
53
    }
54
55
    public function getDefaults()
56
    {
57
        return ['flags' => null];
58
    }
59
}
60