Completed
Push — master ( 59e60c...053593 )
by Song
02:38 queued 11s
created

ControllerCommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 39
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getModelName() 0 4 1
A getControllerName() 0 6 1
1
<?php
2
3
namespace Encore\Admin\Console;
4
5
use Illuminate\Console\GeneratorCommand;
6
use Illuminate\Database\Eloquent\Model;
7
use Illuminate\Support\Str;
8
9
class ControllerCommand extends MakeCommand
10
{
11
    /**
12
     * The console command name.
13
     *
14
     * @var string
15
     */
16
    protected $signature = 'admin:controller {model}
17
        {--title=}
18
        {--stub= : Path to the custom stub file. }
19
        {--namespace=}
20
        {--O|output}';
21
22
    /**
23
     * The console command description.
24
     *
25
     * @var string
26
     */
27
    protected $description = 'Make admin controller from giving model';
28
29
    /**
30
     * @return array|string|null
31
     */
32
    protected function getModelName()
33
    {
34
        return $this->argument('model');
35
    }
36
37
    /**
38
     * @return string
39
     * @throws \ReflectionException
40
     */
41
    protected function getControllerName()
42
    {
43
        $name = (new \ReflectionClass($this->modelName))->getShortName();
44
45
        return $name . 'Controller';
46
    }
47
}
48