CachePoolClearTask::getName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
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\Symfony;
13
14
use Mage\Task\Exception\ErrorException;
15
use Symfony\Component\Process\Process;
16
17
/**
18
 * Symfony Task - Cache Pool Clear
19
 *
20
 * @author Andrés Montañez <[email protected]>
21
 */
22
class CachePoolClearTask extends AbstractSymfonyTask
23
{
24 48
    public function getName(): string
25
    {
26 48
        return 'symfony/cache-pool-clear';
27
    }
28
29 2
    public function getDescription(): string
30
    {
31 2
        return '[Symfony] Cache Pool Clear';
32
    }
33
34 2
    public function execute(): bool
35
    {
36 2
        $options = $this->getOptions();
37
38 2
        if (!$options['pools']) {
39 1
            throw new ErrorException('Parameter "pools" is not defined');
40
        }
41
42 1
        $command = sprintf(
43
            '%s cache:pool:clear %s --env=%s %s',
44 1
            $options['console'],
45 1
            $options['pools'],
46 1
            $options['env'],
47 1
            $options['flags']
48
        );
49
50
        /** @var Process $process */
51 1
        $process = $this->runtime->runCommand(trim($command));
52
53 1
        return $process->isSuccessful();
54
    }
55
56 2
    protected function getSymfonyOptions(): array
57
    {
58 2
        return ['pools' => null];
59
    }
60
}
61