PutIndexSettingsCommand::configure()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1

Importance

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