Completed
Push — master ( a86091...f009d3 )
by GBProd
02:31
created

PutIndexMappingsCommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 41
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
c 1
b 0
f 1
lcom 0
cbo 5
dl 41
loc 41
ccs 26
cts 26
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 17 17 1
A execute() 20 20 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\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
6
use Symfony\Component\Console\Input\InputArgument;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Input\InputOption;
9
use Symfony\Component\Console\Output\OutputInterface;
10
11
/**
12
 * Command to put index mappings
13
 * 
14
 * @author gbprod <[email protected]>
15
 */
16 View Code Duplication
class PutIndexMappingsCommand extends ContainerAwareCommand
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...
17
{
18
    protected function configure()
19
    {
20 1
        $this
21 1
            ->setName('elasticsearch:index:put_mappings')
22 1
            ->setDescription('Put index mappings from configuration')
23 1
            ->addArgument(
24 1
                'client_id',
25 1
                InputArgument::REQUIRED,
26
                'Which client ?'
27 1
            )
28 1
            ->addArgument(
29 1
                'index_id',
30 1
                InputArgument::REQUIRED,
31
                'Which index ?'
32 1
            )
33
        ;
34 1
    }
35
36
    protected function execute(InputInterface $input, OutputInterface $output)
37 1
    {
38 1
        $clientId = $input->getArgument('client_id');
39 1
        $indexId  = $input->getArgument('index_id');
40
        
41 1
        $output->writeln(sprintf(
42 1
            '<info>Put index <comment>%s</comment> settings for client <comment>%s</comment>...</info>',
43 1
            $indexId,
44
            $clientId
45 1
        ));
46
        
47 1
        $handler = $this
48 1
            ->getContainer()
49 1
            ->get('gbprod.elasticsearch_extra.put_index_mappings_handler')
50 1
        ;
51
        
52 1
        $handler->handle($clientId, $indexId);
53
        
54 1
        $output->writeln('done');
55 1
    }
56
}
57