Completed
Branch master (d1a89c)
by Andrés
05:54
created

CleanupTask::getDescription()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 4
Ratio 100 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 4
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 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\Deploy\Tar;
12
13
use Mage\Task\Exception\ErrorException;
14
use Symfony\Component\Process\Process;
15
use Mage\Task\AbstractTask;
16
17
/**
18
 * Tar Task - Delete temporal Tar
19
 *
20
 * @author Andrés Montañez <[email protected]>
21
 */
22 View Code Duplication
class CleanupTask extends AbstractTask
0 ignored issues
show
Duplication introduced by
This class 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...
23
{
24 41
    public function getName()
25
    {
26 41
        return 'deploy/tar/cleanup';
27
    }
28
29 8
    public function getDescription()
30
    {
31 8
        return '[Deploy] Cleanup Tar file';
32
    }
33
34 8
    public function execute()
35
    {
36 8
        if (!$this->runtime->getEnvOption('releases', false)) {
37 2
            throw new ErrorException('This task is only available with releases enabled', 40);
38
        }
39
40 6
        $tarLocal = $this->runtime->getVar('tar_local');
41
42 6
        $cmdDeleteTar = sprintf('rm %s', $tarLocal);
43
44
        /** @var Process $process */
45 6
        $process = $this->runtime->runLocalCommand($cmdDeleteTar);
46 6
        return $process->isSuccessful();
47
    }
48
}
49