Completed
Push — master ( 7fb70a...576e44 )
by Dmitrij
02:22
created

ProcessTemplateFile::__invoke()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 21
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 21
rs 9.3142
c 0
b 0
f 0
cc 3
eloc 12
nc 3
nop 2
1
<?php
2
3
namespace HotRodCli\Processors;
4
5
use HotRodCli\AppContainer;
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Output\OutputInterface;
8
use Symfony\Component\Console\Input\ArrayInput;
9
use Symfony\Component\Console\Application;
10
11
class ProcessTemplateFile
12
{
13
    protected $appContainer;
14
15
    public function __construct(AppContainer $appContainer)
16
    {
17
        $this->appContainer = $appContainer;
18
    }
19
20
    public function __invoke(InputInterface $input, OutputInterface $output)
21
    {
22
        if (!$input->getOption('no-template')) {
23
            $controller = explode('/', $input->getArgument('route'));
24
            $app = $this->appContainer;
25
26
            /** @var Application $application */
27
            $application = $app->resolve(Application::class);
28
            $command = $application->find('create:template');
29
30
            $inputs = array(
31
                'namespace' => $input->getArgument('namespace'),
32
                'template-name' => $controller[2]
33
            );
34
35
            if ($input->getOption('admin')) {
36
                $inputs['--admin'] = true;
37
            }
38
39
            $greetInput = new ArrayInput($inputs);
40
            $command->run($greetInput, $output);
41
        }
42
    }
43
}