CacheClearCommand   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 4
dl 0
loc 35
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 8 1
A execute() 0 15 1
1
<?php
2
3
/*
4
 * This file is part of the ONGR package.
5
 *
6
 * (c) NFQ Technologies UAB <[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 ONGR\ElasticsearchBundle\Command;
13
14
use Symfony\Component\Console\Input\InputInterface;
15
use Symfony\Component\Console\Output\OutputInterface;
16
use Symfony\Component\Console\Style\SymfonyStyle;
17
18
class CacheClearCommand extends AbstractIndexServiceAwareCommand
19
{
20
    const NAME = 'ongr:es:cache:clear';
21
22
    /**
23
     * {@inheritdoc}
24
     */
25
    protected function configure()
26
    {
27
        parent::configure();
28
29
        $this
30
            ->setName(self::NAME)
31
            ->setDescription('Clears ElasticSearch client\'s cache.');
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37
    protected function execute(InputInterface $input, OutputInterface $output)
38
    {
39
        $io = new SymfonyStyle($input, $output);
40
        $index = $this->getIndex($input->getOption('index'));
41
        $index->clearCache();
42
43
        $io->success(
44
            sprintf(
45
                'Elasticsearch `%s` index cache has been cleared.',
46
                $index->getIndexName()
47
            )
48
        );
49
50
        return 0;
51
    }
52
}
53