GeneratorCommand   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 4
dl 0
loc 35
ccs 0
cts 14
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 2
A handle() 0 4 1
A getArguments() 0 6 1
1
<?php
2
3
namespace Recca0120\Generator\Console;
4
5
use Illuminate\Support\Arr;
6
use Illuminate\Console\Command;
7
use Recca0120\Generator\Generator;
8
use Symfony\Component\Console\Input\InputArgument;
9
10
class GeneratorCommand extends Command
11
{
12
    private $generator;
13
14
    private $command;
15
16
    public function __construct(Generator $generator, $command, $config = [])
17
    {
18
        $commandPrefix = Arr::get($config, 'command_prefix', 'generate');
19
        $commandPrefix = empty($commandPrefix) === false ? $commandPrefix.':' : '';
20
21
        $this->generator = $generator;
22
        $this->command = $command;
23
        $this->name = $commandPrefix.$command;
24
25
        parent::__construct();
26
    }
27
28
    public function handle()
29
    {
30
        $this->generator->generate($this->command, $this->argument('name'))->store();
31
    }
32
33
    /**
34
     * Get the console command arguments.
35
     *
36
     * @return array
37
     */
38
    protected function getArguments()
39
    {
40
        return [
41
            ['name', InputArgument::REQUIRED, 'name'],
42
        ];
43
    }
44
}
45