Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Completed
Push — master ( ec4e39...432da1 )
by Cristian
02:06
created

CrudModelBackpackCommand::buildClass()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 6
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 6
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace Backpack\Generators\Console\Commands;
4
5
use Illuminate\Console\GeneratorCommand;
6
7 View Code Duplication
class CrudModelBackpackCommand extends GeneratorCommand
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
8
{
9
    /**
10
     * The console command name.
11
     *
12
     * @var string
13
     */
14
    protected $name = 'backpack:crud-model';
15
16
    /**
17
     * The name and signature of the console command.
18
     *
19
     * @var string
20
     */
21
    protected $signature = 'backpack:crud-model {name}';
22
23
    /**
24
     * The console command description.
25
     *
26
     * @var string
27
     */
28
    protected $description = 'Generate a Backpack CRUD model';
29
30
    /**
31
     * The type of class being generated.
32
     *
33
     * @var string
34
     */
35
    protected $type = 'Model';
36
37
    /**
38
     * Get the stub file for the generator.
39
     *
40
     * @return string
41
     */
42
    protected function getStub()
43
    {
44
        return __DIR__.'/../stubs/crud-model.stub';
45
    }
46
47
    /**
48
     * Get the default namespace for the class.
49
     *
50
     * @param string $rootNamespace
51
     *
52
     * @return string
53
     */
54
    protected function getDefaultNamespace($rootNamespace)
55
    {
56
        return $rootNamespace.'\Models';
57
    }
58
59
    /**
60
     * Replace the table name for the given stub.
61
     *
62
     * @param string $stub
63
     * @param string $name
64
     *
65
     * @return string
66
     */
67
    protected function replaceTable(&$stub, $name)
68
    {
69
        $table = ltrim(strtolower(preg_replace('/[A-Z]/', '_$0', str_replace($this->getNamespace($name).'\\', '', $name))), '_').'s';
70
71
        $stub = str_replace('DummyTable', $table, $stub);
72
73
        return $this;
74
    }
75
76
    /**
77
     * Build the class with the given name.
78
     *
79
     * @param string $name
80
     *
81
     * @return string
82
     */
83
    protected function buildClass($name)
84
    {
85
        $stub = $this->files->get($this->getStub());
86
87
        return $this->replaceNamespace($stub, $name)->replaceTable($stub, $name)->replaceClass($stub, $name);
88
    }
89
90
    /**
91
     * Get the console command options.
92
     *
93
     * @return array
94
     */
95
    protected function getOptions()
96
    {
97
        return [
98
99
        ];
100
    }
101
}
102