Completed
Push — master ( a36c27...010ee5 )
by GBProd
02:47
created

CreateIndexCommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 17 1
A execute() 0 20 1
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 create index
13
 * 
14
 * @author gbprod <[email protected]>
15
 */
16
class CreateIndexCommand extends ContainerAwareCommand
17
{
18
    protected function configure()
19
    {
20 1
        $this
21 1
            ->setName('elasticsearch:create_index')
22 1
            ->setDescription('Create index 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
            'Creating index "%s" for client "%s"...',
43 1
            $indexId,
44
            $clientId
45 1
        ));
46
        
47 1
        $handler = $this
48 1
            ->getContainer()
49 1
            ->get('gbprod.elasticsearch_extra.create_index_handler')
50 1
        ;
51
        
52 1
        $handler->handle($clientId, $indexId);
53
        
54 1
        $output->writeln("Done");
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal Done does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
55
    }
56
}