InitCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 31
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 7 1
A execute() 0 9 2
1
<?php
2
declare(strict_types = 1);
3
namespace T3G\Elasticorn\Commands\Index;
4
5
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Output\OutputInterface;
8
use T3G\Elasticorn\Commands\BaseCommand;
9
10
/**
11
 * Class InitCommand
12
 *
13
 * Command to initialize Elastic index(es)
14
 *
15
 * @package T3G\Elasticorn\Commands
16
 */
17
class InitCommand extends BaseCommand
18
{
19
    /**
20
     * Configure the init command
21
     *
22
     * @return void
23
     */
24
    protected function configure()
25
    {
26
        parent::configure();
27
        $this
28
            ->setName('index:init')
29
            ->setDescription('initializes all configured indices.');
30
    }
31
32
    /**
33
     * @param InputInterface $input
34
     * @param OutputInterface $output
35
     * @return void
36
     */
37
    protected function execute(InputInterface $input, OutputInterface $output)
38
    {
39
        try {
40
            parent::execute($input, $output);
41
            $this->indexService->initIndices();
42
        } catch (\InvalidArgumentException $e) {
43
            $output->writeln('<error>' . $e->getMessage() . '</error>');
44
        }
45
    }
46
47
}