Completed
Push — master ( 501145...c31d74 )
by GBProd
01:44
created

ReindexCommand::execute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 13

Duplication

Lines 21
Ratio 100 %

Code Coverage

Tests 15
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 21
loc 21
ccs 15
cts 15
cp 1
rs 9.3142
c 1
b 0
f 0
cc 1
eloc 13
nc 1
nop 2
crap 1
1
<?php
2
3
namespace GBProd\ElasticaExtraBundle\Command;
4
5
use Symfony\Component\Console\Input\InputArgument;
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Input\InputOption;
8
use Symfony\Component\Console\Output\OutputInterface;
9
10
/**
11
 * Command to reindex
12
 *
13
 * @author gbprod <[email protected]>
14
 */
15 View Code Duplication
class ReindexCommand extends ElasticaAwareCommand
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
16
{
17
    /**
18
     * {@inheritdoc}
19
     */
20 1
    protected function configure()
21
    {
22 1
        $this
23 1
            ->setName('elasticsearch:reindex')
24 1
            ->setDescription('Put index settings from configuration')
25 1
            ->addArgument('old-index', InputArgument::REQUIRED, 'Old index')
26 1
            ->addArgument('new-index', InputArgument::REQUIRED, 'New index')
27 1
            ->addOption('client', null, InputOption::VALUE_REQUIRED, 'Client to use (if not default)', null)
28
        ;
29 1
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34 1
    protected function execute(InputInterface $input, OutputInterface $output)
35
    {
36 1
        $client = $this->getClient($input->getOption('client'));
37 1
        $oldIndex = $input->getArgument('old-index');
38 1
        $newIndex = $input->getArgument('new-index');
39
40 1
        $output->writeln(sprintf(
41 1
            '<info>Reindex <comment>%s</comment> to <comment>%s</comment></info>',
42 1
            $oldIndex,
43
            $newIndex
44 1
        ));
45
46 1
        $handler = $this
47 1
            ->getContainer()
48 1
            ->get('gbprod.elastica_extra.reindex_handler')
49 1
        ;
50
51 1
        $handler->handle($client, $oldIndex, $newIndex);
52
53 1
        $output->writeln('done');
54 1
    }
55
}
56