Passed
Push — stable ( 7698e0...f9d7ca )
by Nuno
03:02
created

CommandMaker   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 100
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 100
ccs 16
cts 16
cp 1
rs 10
c 1
b 0
f 0
wmc 6
lcom 0
cbo 1

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getArguments() 0 6 1
A getOptions() 0 12 1
A replaceClass() 0 6 1
A getNameInput() 0 4 1
A getStub() 0 4 1
A getDefaultNamespace() 0 4 1
1
<?php
2
3
namespace LaravelZero\Framework\Commands\App;
4
5
use Illuminate\Console\GeneratorCommand;
6
use Symfony\Component\Console\Input\InputOption;
7
use Symfony\Component\Console\Input\InputArgument;
8
9
class CommandMaker extends GeneratorCommand
10
{
11
    /**
12
     * The console command name.
13
     *
14
     * @var string
15
     */
16
    protected $name = 'make:command';
17
18
    /**
19
     * The console command description.
20
     *
21
     * @var string
22
     */
23
    protected $description = 'Create a new command';
24
25
    /**
26
     * The type of class being generated.
27
     *
28
     * @var string
29
     */
30
    protected $type = 'Console command';
31
32
    /**
33
     * Replace the class name for the given stub.
34
     *
35
     * @param  string $stub
36
     * @param  string $name
37
     *
38
     * @return string
39
     */
40 1
    protected function replaceClass($stub, $name)
41
    {
42 1
        $stub = parent::replaceClass($stub, $name);
43
44 1
        return str_replace('dummy:command', $this->option('command'), $stub);
45
    }
46
47
    /**
48
     * Get the desired class name from the input.
49
     *
50
     * @return string
51
     */
52 1
    protected function getNameInput()
53
    {
54 1
        return ucfirst(parent::getNameInput());
55
    }
56
57
    /**
58
     * Get the stub file for the generator.
59
     *
60
     * @return string
61
     */
62 1
    protected function getStub()
63
    {
64 1
        return __DIR__.'/stubs/console.stub';
65
    }
66
67
    /**
68
     * Get the default namespace for the class.
69
     *
70
     * @param  string $rootNamespace
71
     *
72
     * @return string
73
     */
74 1
    protected function getDefaultNamespace($rootNamespace)
75
    {
76 1
        return $rootNamespace.'\Commands';
77
    }
78
79
    /**
80
     * Get the console command arguments.
81
     *
82
     * @return array
83
     */
84 47
    protected function getArguments()
85
    {
86
        return [
87 47
            ['name', InputArgument::REQUIRED, 'The name of the command.'],
88
        ];
89
    }
90
91
    /**
92
     * Get the console command options.
93
     *
94
     * @return array
95
     */
96 47
    protected function getOptions()
97
    {
98
        return [
99
            [
100 47
                'command',
101
                null,
102 47
                InputOption::VALUE_OPTIONAL,
103 47
                'The terminal command that should be assigned.',
104 47
                'command:name',
105
            ],
106
        ];
107
    }
108
}
109