CreateIndexCommand::configure()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 9
Ratio 100 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
dl 9
loc 9
ccs 6
cts 6
cp 1
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 0
crap 1
1
<?php
2
3
namespace GBProd\ElasticsearchExtraBundle\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 create index
12
 *
13
 * @author gbprod <[email protected]>
14
 */
15 View Code Duplication
class CreateIndexCommand extends ElasticsearchAwareCommand
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
    protected function configure()
18
    {
19 1
        $this
20 1
            ->setName('elasticsearch:index:create')
21 1
            ->setDescription('Create index from configuration')
22 1
            ->addArgument('index', InputArgument::REQUIRED, 'Which index ?')
23 1
            ->addOption('client', null, InputOption::VALUE_REQUIRED, 'Client to use (if not default)', 'default')
24
        ;
25 1
    }
26
27
    protected function execute(InputInterface $input, OutputInterface $output)
28
    {
29 1
        $client = $this->getClient($input->getOption('client'));
30 1
        $index  = $input->getArgument('index');
31
32 1
        $output->writeln(sprintf(
33 1
            '<info>Creating index <comment>%s</comment> for client <comment>%s</comment></info>',
34 1
            $index,
35 1
            $input->getOption('client')
36 1
        ));
37 1
38 1
        $handler = $this
39 1
            ->getContainer()
40 1
            ->get('gbprod.elasticsearch_extra.create_index_handler')
41 1
        ;
42 1
43 1
        $handler->handle($client, $index);
44
45 1
        $output->writeln('done');
46 1
    }
47
}
48