Passed
Push — master ( 23dae9...6563ef )
by Andrés
01:14
created

CachePoolClearTask   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 4
dl 0
loc 33
ccs 0
cts 22
cp 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 4 1
A getDescription() 0 4 1
A execute() 0 15 2
A getSymfonyOptions() 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\Symfony;
12
13
use Mage\Task\Exception\ErrorException;
14
use Symfony\Component\Process\Process;
15
16
/**
17
 * Symfony Task - Cache Pool Clear
18
 *
19
 * @author Andrés Montañez <[email protected]>
20
 */
21
class CachePoolClearTask extends AbstractSymfonyTask
22
{
23
    public function getName()
24
    {
25
        return 'symfony/cache-pool-clear';
26
    }
27
28
    public function getDescription()
29
    {
30
        return '[Symfony] Cache Pool Clear';
31
    }
32
33
    public function execute()
34
    {
35
        $options = $this->getOptions();
36
37
        if (!$options['pools']) {
38
            throw new ErrorException('Parameter "pools" is not defined');
39
        }
40
41
        $command = $options['console'] . ' cache:pool:clear ' . $options['pools'] . ' --env=' . $options['env'] . ' ' . $options['flags'];
42
43
        /** @var Process $process */
44
        $process = $this->runtime->runCommand(trim($command));
45
46
        return $process->isSuccessful();
47
    }
48
49
    protected function getSymfonyOptions()
50
    {
51
        return ['pools' => null];
52
    }
53
}
54