RunProcessCommand::configure()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 7
ccs 0
cts 7
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace Xervice\Processor\Communication\Console;
5
6
7
use DataProvider\ProcessRunDataProvider;
8
use Symfony\Component\Console\Input\InputInterface;
9
use Symfony\Component\Console\Input\InputOption;
10
use Symfony\Component\Console\Output\OutputInterface;
11
use Xervice\Console\Business\Model\Command\AbstractCommand;
12
13
/**
14
 * @method \Xervice\Processor\Business\ProcessorFacade getFacade()
15
 */
16
class RunProcessCommand extends AbstractCommand
17
{
18
    protected function configure()
19
    {
20
        $this
21
            ->setName('process:run')
22
            ->addOption('process', 'p', InputOption::VALUE_REQUIRED, 'Process name')
23
            ->addOption('output', 'o', InputOption::VALUE_REQUIRED, 'Output file')
24
            ->addOption('input', 'i', InputOption::VALUE_REQUIRED, 'Input file');
25
    }
26
27
    /**
28
     * @param \Symfony\Component\Console\Input\InputInterface $input
29
     * @param \Symfony\Component\Console\Output\OutputInterface $output
30
     *
31
     * @return int|void|null
32
     */
33
    protected function execute(InputInterface $input, OutputInterface $output)
34
    {
35
        $processName = $input->getOption('process');
36
        $inputFile = $input->getOption('input');
37
        $outputFile = $input->getOption('output');
38
39
        $process = (new ProcessRunDataProvider())
40
            ->setName($processName)
41
            ->setInput($inputFile)
42
            ->setOutput($outputFile);
43
44
        $this->getFacade()->runProcess($process);
45
    }
46
}