PutIndexMappingsCommand::configure()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 11
Ratio 100 %

Code Coverage

Tests 9
CRAP Score 1

Importance

Changes 0
Metric Value
dl 11
loc 11
ccs 9
cts 9
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 0
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 put index mappings
12
 *
13
 * @author gbprod <[email protected]>
14
 */
15
class PutIndexMappingsCommand extends ElasticaAwareCommand
16
{
17 2 View Code Duplication
    protected function configure()
0 ignored issues
show
Duplication introduced by
This method 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...
18
    {
19 2
        $this
20 2
            ->setName('elasticsearch:index:put_mappings')
21 2
            ->setDescription('Put index mappings from configuration')
22 2
            ->addArgument('index', InputArgument::REQUIRED, 'Which index ?')
23 2
            ->addArgument('type', InputArgument::REQUIRED, 'Which type ?')
24 2
            ->addOption('client', null, InputOption::VALUE_REQUIRED, 'Client to use (if not default)', null)
25 2
            ->addOption('alias', null, InputOption::VALUE_REQUIRED, 'Index configuration to use (if not the same as index argument)', null)
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 139 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
26
        ;
27 2
    }
28
29 2
    protected function execute(InputInterface $input, OutputInterface $output)
30
    {
31 2
        $client = $this->getClient($input->getOption('client'));
32 2
        $index  = $input->getArgument('index');
33 2
        $type   = $input->getArgument('type');
34 2
        $alias  = $input->getOption('alias') ?: $index;
35
36 2
        $output->writeln(sprintf(
37
            '<info>Put type <comment>%s</comment> mappings for index <comment>%s</comment> '.
38 2
            'client <comment>%s</comment>...</info>',
39 2
            $type,
40 2
            $index,
41 2
            $input->getOption('client')
42 2
        ));
43
44 2
        $handler = $this
45 2
            ->getContainer()
46 2
            ->get('gbprod.elastica_extra.put_index_mappings_handler')
47 2
        ;
48
49 2
        $handler->handle($client, $index, $type, $alias);
50
51 2
        $output->writeln('done');
52 2
    }
53
}
54