Passed
Push — master ( 2fd2da...07f956 )
by Arthur
35:40 queued 30:04
created

CommandMakeCommand::getCommandName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Foundation\Generator\Commands;
4
5
use Foundation\Generator\Abstracts\AbstractGeneratorCommand;
6
use Symfony\Component\Console\Input\InputOption;
7
8
class CommandMakeCommand extends AbstractGeneratorCommand
9
{
10
    /**
11
     * The console command name.
12
     *
13
     * @var string
14
     */
15
    protected $name = 'larapi:make:command';
16
17
    /**
18
     * The console command description.
19
     *
20
     * @var string
21
     */
22
    protected $description = 'Generate new Artisan command for the specified module.';
23
24
    /**
25
     * The name of the generated resource.
26
     *
27
     * @var string
28
     */
29
    protected $generatorName = 'command';
30
31
    /**
32
     * The stub name.
33
     *
34
     * @var string
35
     */
36
    protected $stub = 'command.stub';
37
38
    /**
39
     * The file path.
40
     *
41
     * @var string
42
     */
43
    protected $filePath = '/Console';
44
45 1
    protected function stubOptions(): array
46
    {
47
        return [
48 1
            'CLASS' => $this->getClassName(),
49 1
            'COMMAND_NAME' => $this->getCommandName(),
50 1
            'NAMESPACE' => $this->getClassNamespace(),
51
        ];
52
    }
53
54
    /**
55
     * Get the console command options.
56
     *
57
     * @return array
58
     */
59 102
    protected function getOptions()
60
    {
61
        return [
62 102
            ['command', null, InputOption::VALUE_OPTIONAL, 'The terminal command that should be assigned.', null],
63
        ];
64
    }
65
66
    /**
67
     * @return string
68
     */
69 1
    private function getCommandName()
70
    {
71 1
        return $this->option('command') ?? str_replace('command', '', strtolower($this->getModuleName()).':'.strtolower($this->getClassName()));
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->option('co...$this->getClassName())) also could return the type boolean|string[] which is incompatible with the documented return type string.
Loading history...
72
    }
73
}
74