ObserverMakeCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 0
cbo 2
dl 0
loc 45
ccs 0
cts 19
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getStub() 0 4 1
A getDefaultNamespace() 0 4 1
A getComponentNamespace() 0 11 1
1
<?php
2
3
namespace Sco\Admin\Console;
4
5
use Illuminate\Console\GeneratorCommand;
6
use Illuminate\Support\Str;
7
8
class ObserverMakeCommand extends GeneratorCommand
9
{
10
    /**
11
     * The console command name.
12
     *
13
     * @var string
14
     */
15
    protected $name = 'make:observer';
16
17
    /**
18
     * The console command description.
19
     *
20
     * @var string
21
     */
22
    protected $description = 'Create a new access observer class(Sco-Admin)';
23
24
    /**
25
     * The type of class being generated.
26
     *
27
     * @var string
28
     */
29
    protected $type = 'Observer';
30
31
    protected function getStub()
32
    {
33
        return __DIR__ . '/stubs/observer.stub';
34
    }
35
36
    protected function getDefaultNamespace($rootNamespace)
37
    {
38
        return $rootNamespace . '\\' . $this->getComponentNamespace() . '\Observers';
39
    }
40
41
    protected function getComponentNamespace()
42
    {
43
        return str_replace(
44
            '/',
45
            '\\',
46
            Str::after(
47
                config('admin.components'),
48
                app_path() . DIRECTORY_SEPARATOR
49
            )
50
        );
51
    }
52
}
53