PutIndexMappingsCommand::execute()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 17
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 23
ccs 17
cts 17
cp 1
rs 9.0856
c 0
b 0
f 0
cc 1
eloc 15
nc 1
nop 2
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 put index mappings
12
 *
13
 * @author gbprod <[email protected]>
14
 */
15
class PutIndexMappingsCommand extends ElasticsearchAwareCommand
16
{
17 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 1
        $this
20 1
            ->setName('elasticsearch:index:put_mappings')
21 1
            ->setDescription('Put index mappings from configuration')
22 1
            ->addArgument('index', InputArgument::REQUIRED, 'Which index ?')
23 1
            ->addArgument('type', InputArgument::REQUIRED, 'Which type ?')
24 1
            ->addOption('client', null, InputOption::VALUE_REQUIRED, 'Client to use (if not default)', 'default')
25
        ;
26 1
    }
27
28
    protected function execute(InputInterface $input, OutputInterface $output)
29
    {
30 1
        $client = $this->getClient($input->getOption('client'));
31 1
        $index  = $input->getArgument('index');
32 1
        $type   = $input->getArgument('type');
33
34 1
        $output->writeln(sprintf(
35 1
            '<info>Put type <comment>%s</comment> mappings for index <comment>%s</comment> ' .
36 1
            'client <comment>%s</comment>...</info>',
37 1
            $type,
38 1
            $index,
39 1
            $input->getOption('client')
40 1
        ));
41
42 1
        $handler = $this
43 1
            ->getContainer()
44 1
            ->get('gbprod.elasticsearch_extra.put_index_mappings_handler')
45 1
        ;
46
47 1
        $handler->handle($client, $index, $type);
48
49 1
        $output->writeln('done');
50 1
    }
51
}
52