ProcessRepository::__invoke()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 17
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
namespace HotRodCli\Processors;
4
5
use HotRodCli\AppContainer;
6
use Symfony\Component\Console\Application;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Output\OutputInterface;
9
use Symfony\Component\Console\Input\ArrayInput;
10
11
class ProcessRepository
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
        $namespace = explode('_', $input->getArgument('namespace'));
23
        $app = $this->appContainer;
24
25
        /** @var Application $application */
26
        $application = $app->resolve(Application::class);
27
        $command = $application->find('create:repository');
28
29
        $inputs = array(
30
            'namespace' => $input->getArgument('namespace'),
31
            'interface-name' => $input->getArgument('name') . 'RepositoryInterface',
32
            'model-class' => $namespace[0] . '\\' . $namespace[1] . '\\Model\\' . $input->getArgument('name')
33
        );
34
35
        $greetInput = new ArrayInput($inputs);
36
        $command->run($greetInput, $output);
37
    }
38
}
39