GeneratorCommand::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 0
cts 8
cp 0
rs 9.9
c 0
b 0
f 0
cc 2
nc 2
nop 3
crap 6
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