GetDefinitionCommand::configure()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Oliverde8\PhpEtlBundle\Command;
4
5
use Oliverde8\PhpEtlBundle\Services\ChainProcessorsManager;
6
use Symfony\Component\Console\Command\Command;
7
use Symfony\Component\Console\Input\InputArgument;
8
use Symfony\Component\Console\Input\InputInterface;
9
use Symfony\Component\Console\Output\OutputInterface;
10
use Symfony\Component\Yaml\Yaml;
11
12
class GetDefinitionCommand extends Command
13
{
14
    protected ChainProcessorsManager $chainProcessorsManager;
15
16
    /**
17
     * ExecuteCommand constructor.
18
     * @param ChainProcessorsManager $chainProcessorsManager
19
     */
20
    public function __construct(ChainProcessorsManager $chainProcessorsManager)
21
    {
22
        parent::__construct();
23
        $this->chainProcessorsManager = $chainProcessorsManager;
24
    }
25
26
27
    protected function configure()
28
    {
29
        $this->setName("etl:get-definition");
30
        $this->addArgument("name", InputArgument::REQUIRED);
31
    }
32
33
    /**
34
     * @throws \Oliverde8\Component\PhpEtl\Exception\ChainOperationException
35
     */
36
    protected function execute(InputInterface $input, OutputInterface $output)
37
    {
38
        $chainName = $input->getArgument("name");
39
        $definition = $this->chainProcessorsManager->getRawDefinition($chainName);
40
41
        echo Yaml::dump($definition, 4);
42
        return 0;
43
    }
44
}
45