Passed
Branch master (3fb2a1)
by Andrés
02:45
created

CleanupTask   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 9
c 0
b 0
f 0
dl 0
loc 25
ccs 11
cts 11
cp 1
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 3 1
A execute() 0 13 2
A getDescription() 0 3 1
1
<?php
2
3
/*
4
 * This file is part of the Magallanes package.
5
 *
6
 * (c) Andrés Montañez <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Mage\Task\BuiltIn\Deploy\Tar;
13
14
use Mage\Task\Exception\ErrorException;
15
use Symfony\Component\Process\Process;
16
use Mage\Task\AbstractTask;
17
18
/**
19
 * Tar Task - Delete temporal Tar
20
 *
21
 * @author Andrés Montañez <[email protected]>
22
 */
23
class CleanupTask extends AbstractTask
24
{
25 48
    public function getName(): string
26
    {
27 48
        return 'deploy/tar/cleanup';
28
    }
29
30 13
    public function getDescription(): string
31
    {
32 13
        return '[Deploy] Cleanup Tar file';
33
    }
34
35 13
    public function execute(): bool
36
    {
37 13
        if (!$this->runtime->getEnvOption('releases', false)) {
38 2
            throw new ErrorException('This task is only available with releases enabled', 40);
39
        }
40
41 11
        $tarLocal = $this->runtime->getVar('tar_local');
42
43 11
        $cmdDeleteTar = sprintf('rm %s', $tarLocal);
44
45
        /** @var Process $process */
46 11
        $process = $this->runtime->runLocalCommand($cmdDeleteTar);
47 11
        return $process->isSuccessful();
48
    }
49
}
50