PutIndexMappingsCommand   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 27.03 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 5
dl 10
loc 37
ccs 24
cts 24
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 10 10 1
A execute() 0 23 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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