GearmanCacheClearCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 4
dl 0
loc 38
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 9 1
A execute() 0 11 2
1
<?php
2
3
/**
4
 * Gearman Bundle for Symfony2 / Symfony3
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 *
9
 * Feel free to edit as you please, and have fun.
10
 *
11
 * @author Marc Morera <[email protected]>
12
 * @author Mickael Perraud <[email protected]>
13
 */
14
15
namespace Mkk\GearmanBundle\Command;
16
17
use Symfony\Component\Console\Input\InputInterface;
18
use Symfony\Component\Console\Output\OutputInterface;
19
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
20
21
/**
22
 * Clears all cache data
23
 */
24
class GearmanCacheClearCommand extends ContainerAwareCommand
25
{
26
27
    /**
28
     * Console Command configuration
29
     */
30 16
    protected function configure()
31
    {
32
        $this
33 16
            ->setName('gearman:cache:clear')
34 16
            ->setAliases(array(
35 16
                'cache:gearman:clear'
36
            ))
37 16
            ->setDescription('Clears gearman cache data on current environment');
38 16
    }
39
40
    /**
41
     * Executes the current command.
42
     *
43
     * @param InputInterface  $input  An InputInterface instance
44
     * @param OutputInterface $output An OutputInterface instance
45
     *
46
     * @return null|int null or 0 if everything went fine, or an error code
47
     *
48
     * @throws \LogicException When this abstract class is not implemented
49
     */
50 2
    protected function execute(InputInterface $input, OutputInterface $output)
51
    {
52 2
        if (!$input->getOption('quiet')) {
53 1
            $environment = $this->getContainer()->getParameter('kernel.environment');
54 1
            $output->writeln('Clearing the cache for the ' . $environment . ' environment');
55
        }
56
        $this
57 2
            ->getContainer()
58 2
            ->get('gearman.cache.wrapper')
59 2
            ->clear('');
60 2
    }
61
}
62