ShowCommand::execute()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
declare(strict_types = 1);
3
namespace T3G\Elasticorn\Commands\Mapping;
4
5
use Symfony\Component\Console\Input\InputArgument;
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Output\OutputInterface;
8
use Symfony\Component\Yaml\Yaml;
9
use T3G\Elasticorn\Commands\BaseCommand;
10
11
/**
12
 * @package T3G\Elasticorn\Commands
13
 */
14
class ShowCommand extends BaseCommand
15
{
16
    /**
17
     * Configure the init command
18
     *
19
     * @return void
20
     */
21
    protected function configure()
22
    {
23
        parent::configure();
24
        $this
25
            ->setName('mapping:show')
26
            ->setDescription('show currently applied mapping configuration.');
27
28
        $this->
29
            addArgument('indexName', InputArgument::REQUIRED, 'The index name.');
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
        parent::execute($input, $output);
40
        $mapping = $this->indexService->getMappingForIndex();
41
        $dump = Yaml::dump($mapping, 20, 4, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK);
42
        $output->write(
43
            $dump
44
        );
45
    }
46
47
}