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

CachePoolClearTask   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

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

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 41
    public function getName()
24
    {
25 41
        return 'symfony/cache-pool-clear';
26
    }
27
28 2
    public function getDescription()
29
    {
30 2
        return '[Symfony] Cache Pool Clear';
31
    }
32
33 2
    public function execute()
34
    {
35 2
        $options = $this->getOptions();
36
37 2
        if (!$options['pools']) {
38 1
            throw new ErrorException('Parameter "pools" is not defined');
39
        }
40
41 1
        $command = $options['console'] . ' cache:pool:clear ' . $options['pools'] . ' --env=' . $options['env'] . ' ' . $options['flags'];
42
43
        /** @var Process $process */
44 1
        $process = $this->runtime->runCommand(trim($command));
45
46 1
        return $process->isSuccessful();
47
    }
48
49 2
    protected function getSymfonyOptions()
50
    {
51 2
        return ['pools' => null];
52
    }
53
}
54