Passed
Push — master ( 178c96...019b79 )
by Dominik
02:35
created

NodeGeneratorCommand::execute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 9
ccs 5
cts 5
cp 1
rs 9.6666
cc 1
eloc 5
nc 1
nop 2
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Saxulum\ElasticSearchQueryBuilder\Generator\Command;
6
7
use PhpParser\PrettyPrinter\Standard as PhpGenerator;
8
use Saxulum\ElasticSearchQueryBuilder\Generator\NodeGenerator;
9
use Symfony\Component\Console\Command\Command;
10
use Symfony\Component\Console\Input\InputArgument;
11
use Symfony\Component\Console\Input\InputInterface;
12
use Symfony\Component\Console\Output\OutputInterface;
13
14
final class NodeGeneratorCommand extends Command
15
{
16 1
    protected function configure()
17
    {
18
        $this
19 1
            ->setName('saxulum:elasticsearch:querybuilder:generator:node')
20 1
            ->setDescription('Generate the node code of a elasticsearch json query.')
21 1
            ->addArgument('query', InputArgument::REQUIRED, 'The json query.')
22
        ;
23 1
    }
24
25
    /**
26
     * @param InputInterface  $input
27
     * @param OutputInterface $output
28
     * @return int
29
     */
30 1
    protected function execute(InputInterface $input, OutputInterface $output)
31
    {
32 1
        $generator = new NodeGenerator(new PhpGenerator());
33
34 1
        $output->writeln('<info>Generated code:</info>');
35 1
        $output->writeln($generator->generateByJson($input->getArgument('query')));
36
37 1
        return 0;
38
    }
39
}
40