Completed
Push — master ( 355f41...200862 )
by Mickael
06:25
created

GearmanCacheClearCommand::setGearmanCacheWrapper()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
crap 1
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
 */
13
14
namespace Mkk\GearmanBundle\Command;
15
16
use Symfony\Component\Console\Input\InputInterface;
17
use Symfony\Component\Console\Output\OutputInterface;
18
use Mkk\GearmanBundle\Command\Abstracts\AbstractGearmanCommand;
19
use Mkk\GearmanBundle\Service\GearmanCacheWrapper;
20
21
/**
22
 * Clears all cache data
23
 */
24
class GearmanCacheClearCommand extends AbstractGearmanCommand
25
{
26
    /**
27
     * @var GearmanCacheWrapper
28
     *
29
     * GearmanCacheWrapper
30
     */
31
    protected $gearmanCacheWrapper;
32
33
    /**
34
     * Set the GearmanCacheWrapper instance
35
     *
36
     * @param GearmanCacheWrapper $gearmanCacheWrapper GearmanCacheWrapper
37
     *
38
     * @return GearmanCacheClearCommand self Object
39
     */
40 2
    public function setGearmanCacheWrapper(GearmanCacheWrapper $gearmanCacheWrapper)
41
    {
42 2
        $this->gearmanCacheWrapper = $gearmanCacheWrapper;
43
44 2
        return $this;
45
    }
46
47
    /**
48
     * Console Command configuration
49
     */
50 2
    protected function configure()
51
    {
52
        $this
53 2
            ->setName('gearman:cache:clear')
54 2
            ->setAliases(array(
55
                'cache:gearman:clear'
56 2
            ))
57 2
            ->setDescription('Clears gearman cache data on current environment');
58 2
    }
59
60
    /**
61
     * Executes the current command.
62
     *
63
     * @param InputInterface  $input  An InputInterface instance
64
     * @param OutputInterface $output An OutputInterface instance
65
     *
66
     * @return null|int null or 0 if everything went fine, or an error code
67
     *
68
     * @throws \LogicException When this abstract class is not implemented
69
     */
70 2
    protected function execute(InputInterface $input, OutputInterface $output)
71
    {
72
        if (
73 2
            !$input->getOption('quiet')
74
        ) {
75
            $kernelEnvironment = $this
76 1
                ->kernel
77 1
                ->getEnvironment();
78
79 1
            $output->writeln('Clearing the cache for the ' . $kernelEnvironment . ' environment');
80
        }
81
        $this
82 2
            ->gearmanCacheWrapper
83 2
            ->clear('');
84 2
    }
85
}
0 ignored issues
show
Coding Style introduced by
As per coding style, files should not end with a newline character.

This check marks files that end in a newline character, i.e. an empy line.

Loading history...
86