Code Duplication    Length = 33-33 lines in 2 locations

src/ElasticsearchExtraBundle/Command/CreateIndexCommand.php 1 location

@@ 15-47 (lines=33) @@
12
 *
13
 * @author gbprod <[email protected]>
14
 */
15
class CreateIndexCommand extends ElasticsearchAwareCommand
16
{
17
    protected function configure()
18
    {
19
        $this
20
            ->setName('elasticsearch:index:create')
21
            ->setDescription('Create index from configuration')
22
            ->addArgument('index', InputArgument::REQUIRED, 'Which index ?')
23
            ->addOption('client', null, InputOption::VALUE_REQUIRED, 'Client to use (if not default)', 'default')
24
        ;
25
    }
26
27
    protected function execute(InputInterface $input, OutputInterface $output)
28
    {
29
        $client = $this->getClient($input->getOption('client'));
30
        $index  = $input->getArgument('index');
31
32
        $output->writeln(sprintf(
33
            '<info>Creating index <comment>%s</comment> for client <comment>%s</comment></info>',
34
            $index,
35
            $input->getOption('client')
36
        ));
37
38
        $handler = $this
39
            ->getContainer()
40
            ->get('gbprod.elasticsearch_extra.create_index_handler')
41
        ;
42
43
        $handler->handle($client, $index);
44
45
        $output->writeln('done');
46
    }
47
}
48

src/ElasticsearchExtraBundle/Command/PutIndexSettingsCommand.php 1 location

@@ 15-47 (lines=33) @@
12
 *
13
 * @author gbprod <[email protected]>
14
 */
15
class PutIndexSettingsCommand extends ElasticsearchAwareCommand
16
{
17
    protected function configure()
18
    {
19
        $this
20
            ->setName('elasticsearch:index:put_settings')
21
            ->setDescription('Put index settings from configuration')
22
            ->addArgument('index', InputArgument::REQUIRED, 'Which index ?')
23
            ->addOption('client', null, InputOption::VALUE_REQUIRED, 'Client to use (if not default)', 'default')
24
        ;
25
    }
26
27
    protected function execute(InputInterface $input, OutputInterface $output)
28
    {
29
        $client = $this->getClient($input->getOption('client'));
30
        $index  = $input->getArgument('index');
31
32
        $output->writeln(sprintf(
33
            '<info>Put index <comment>%s</comment> settings for client <comment>%s</comment>...</info>',
34
            $index,
35
            $input->getOption('client')
36
        ));
37
38
        $handler = $this
39
            ->getContainer()
40
            ->get('gbprod.elasticsearch_extra.put_index_settings_handler')
41
        ;
42
43
        $handler->handle($client, $index);
44
45
        $output->writeln('done');
46
    }
47
}
48