SimpleScript   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 16
dl 0
loc 29
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A __invoke() 0 20 2
1
<?php
2
3
namespace HotRodCli\Processors\ScriptFile;
4
5
use HotRodCli\AppContainer;
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Output\OutputInterface;
8
use HotRodCli\Jobs\Js\AddJs;
9
use HotRodCli\Jobs\Filesystem\CopyFile;
10
11
class SimpleScript
12
{
13
    protected $container;
14
15
    public function __construct(AppContainer $appContainer)
16
    {
17
        $this->container = $appContainer;
18
    }
19
20
    public function __invoke(InputInterface $input, OutputInterface $output)
21
    {
22
        $namespace = explode('_', $input->getArgument('namespace'));
23
        $app = $this->container;
24
        $scope = $input->getOption('admin') ? 'adminhtml' : 'frontend';
25
26
        $this->container->resolve(AddJs::class)->handle(
27
            $app->get('app_dir') . '/app/code/' . $namespace[0] . '/' . $namespace[1] . '/view/' . $scope . '/requirejs-config.js',
28
            $input->getArgument('script-name'),
29
            $input->getArgument('namespace') . '/js/' . $input->getArgument('script-name')
30
        );
31
32
        $this->container->resolve(CopyFile::class)->handle(
33
            $app->get('resource_dir') . '/frontend/simple-js.js',
34
            $app->get('app_dir') . '/app/code/' . $namespace[0] . '/'
35
            . $namespace[1] . '/view/' . $scope . '/web/js/' . $input->getArgument('script-name') . '.js'
36
        );
37
38
        $output->writeln('<info>' . '/app/code/' . $namespace[0] . '/'
39
            . $namespace[1] . '/view/' . $scope . '/web/js/' . $input->getArgument('script-name') . '.js successfully generated</info>');
40
    }
41
}
42