Completed
Push — 1.0 ( 731e1a...f45751 )
by Simonas
9s
created

CacheClearCommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 2
c 2
b 1
f 0
lcom 0
cbo 5
dl 0
loc 31
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 13 1
A configure() 0 8 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
/**
19
 * Symfony command for clearing elasticsearch cache.
20
 */
21
class CacheClearCommand extends AbstractManagerAwareCommand
22
{
23
    /**
24
     * {@inheritdoc}
25
     */
26
    protected function configure()
27
    {
28
        parent::configure();
29
30
        $this
31
            ->setName('ongr:es:cache:clear')
32
            ->setDescription('Clears elasticsearch client cache.');
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    protected function execute(InputInterface $input, OutputInterface $output)
39
    {
40
        $io = new SymfonyStyle($input, $output);
41
        $this
42
            ->getManager($input->getOption('manager'))
43
            ->clearCache();
44
        $io->success(
45
            sprintf(
46
                'Elasticsearch index cache has been cleared for manager named `%s`',
47
                $input->getOption('manager')
48
            )
49
        );
50
    }
51
}
52