Passed
Push — master ( 139939...b4b8e8 )
by Arthur
21:54 queued 17s
created

ModuleMakeCommand::handle()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 10
nc 2
nop 0
dl 0
loc 13
rs 9.9332
c 0
b 0
f 0
1
<?php
2
3
namespace Foundation\Generator\Commands;
4
5
use Illuminate\Console\Command;
6
use Nwidart\Modules\Generators\ModuleGenerator;
7
use Symfony\Component\Console\Input\InputArgument;
8
use Symfony\Component\Console\Input\InputOption;
9
10
class ModuleMakeCommand extends \Nwidart\Modules\Commands\ModuleMakeCommand
11
{
12
    /**
13
     * The console command name.
14
     *
15
     * @var string
16
     */
17
    protected $name = 'larapi:make-module';
18
19
    /**
20
     * The console command description.
21
     *
22
     * @var string
23
     */
24
    protected $description = 'Create a new module.';
25
26
    /**
27
     * Execute the console command.
28
     */
29
    public function handle()
30
    {
31
        $names = $this->argument('name');
32
33
        foreach ($names as $name) {
34
            with(new ModuleGenerator($name))
35
                ->setFilesystem($this->laravel['files'])
36
                ->setModule($this->laravel['modules'])
37
                ->setConfig($this->laravel['config'])
38
                ->setConsole($this)
39
                ->setForce($this->option('force'))
40
                ->setPlain($this->option('plain'))
41
                ->generate();
42
        }
43
    }
44
45
    /**
46
     * Get the console command arguments.
47
     *
48
     * @return array
49
     */
50
    protected function getArguments()
51
    {
52
        return [
53
            ['name', InputArgument::IS_ARRAY, 'The names of modules will be created.'],
54
        ];
55
    }
56
57
    protected function getOptions()
58
    {
59
        return [
60
            ['plain', 'p', InputOption::VALUE_NONE, 'Generate a plain module (without some resources).'],
61
            ['force', null, InputOption::VALUE_NONE, 'Force the operation to run when the module already exists.'],
62
        ];
63
    }
64
}
65