GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( adda48...bcebe0 )
by Marceau
08:15
created

CrudControllerMakeCommand::getStub()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Akibatech\Crud\Console;
4
5
use Illuminate\Console\GeneratorCommand;
6
use Illuminate\Support\Str;
7
use Symfony\Component\Console\Input\InputArgument;
8
use Symfony\Component\Console\Input\InputOption;
9
10
class CrudControllerMakeCommand extends GeneratorCommand
11
{
12
    /**
13
     * @var string
14
     */
15
    protected $name = 'make:crud:controller';
16
17
    /**
18
     * @var string
19
     */
20
    protected $description = 'Create a new crud friendly controller class';
21
22
    /**
23
     * @var string
24
     */
25
    protected $type = 'Controller';
26
27
    /**
28
     * @return  string
29
     */
30
    protected function getStub()
31
    {
32
        return __DIR__.'/stubs/controller.stub';
33
    }
34
35
    /**
36
     * @param   string  $rootNamespace
37
     * @return  string
38
     */
39
    protected function getDefaultNamespace($rootNamespace)
40
    {
41
        return $rootNamespace.'\Http\Controllers';
42
    }
43
44
    /**
45
     * Get and parse the model name.
46
     *
47
     * @param   void
48
     * @return  string
49
     */
50
    protected function getModelName()
51
    {
52
        $name = trim($this->argument('model'));
53
        $rootNamespace = $this->laravel->getNamespace();
54
55
        if (Str::contains($name, '/'))
56
        {
57
            $name = str_replace('/', '\\', $name);
58
        }
59
60
        if (Str::startsWith($name, $rootNamespace))
61
        {
62
            return '\\' . $name;
63
        }
64
65
        return '\\' . $rootNamespace . $name;
66
    }
67
68
    /**
69
     * @return array
70
     */
71
    protected function getArguments()
72
    {
73
        return array_merge(parent::getArguments(), [
74
            ['model', InputArgument::REQUIRED, 'The name of the model, for example, "Post" or "App/Post"'],
75
        ]);
76
    }
77
78
    /**
79
     * @param   string  $name
80
     * @return  string
81
     */
82
    protected function buildClass($name)
83
    {
84
        $namespace = $this->getNamespace($name);
85
86
        $modelName = $this->getModelName();
87
        $modelClass = $modelName . '::class';
88
89
        $class = parent::buildClass($name);
90
        $class = str_replace("use {$namespace}\Controller;\n", '', $class);
91
        $class = str_replace('DummyModelClass', $modelClass, $class);
92
        $class = str_replace('DummyModel', $modelName, $class);
93
94
        return $class;
95
    }
96
}
97