Completed
Push — master ( 7f011d...511c4e )
by recca
04:58
created

GeneratorCommand   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 42.86%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 48
ccs 6
cts 14
cp 0.4286
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A rootNamespace() 0 4 1
A qualifyClass() 0 14 2
1
<?php
2
3
namespace Recca0120\Generator\Console;
4
5
use Illuminate\Support\Str;
6
use Recca0120\Generator\Generator;
7
use Illuminate\Filesystem\Filesystem;
8
use Illuminate\Console\GeneratorCommand as BaseCommand;
9
10
abstract class GeneratorCommand extends BaseCommand
11
{
12
    protected $generator;
13
14
    /**
15
     * Create a new controller creator command instance.
16
     *
17
     * @param \Illuminate\Filesystem\Filesystem $files
18
     */
19 6
    public function __construct(Filesystem $files, Generator $generator)
20
    {
21 6
        parent::__construct($files);
22
23 6
        $this->generator = $generator;
24 6
    }
25
26
    /**
27
     * Parse the class name and format according to the root namespace.
28
     *
29
     * @param string $name
30
     *
31
     * @return string
32
     */
33
    protected function qualifyClass($name)
34
    {
35
        $rootNamespace = $this->rootNamespace();
36
37
        if (Str::startsWith($name, $rootNamespace)) {
38
            return $name;
39
        }
40
41
        $name = str_replace('/', '\\', $name);
42
43
        return $this->qualifyClass(
44
            $this->getDefaultNamespace(trim($rootNamespace, '\\')).'\\'.$name
45
        );
46
    }
47
48
    /**
49
     * Get the root namespace for the class.
50
     *
51
     * @return string
52
     */
53 3
    protected function rootNamespace()
54
    {
55 3
        return $this->laravel->getNamespace();
1 ignored issue
show
Bug introduced by
The method getNamespace() does not seem to exist on object<Illuminate\Contra...Foundation\Application>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
56
    }
57
}
58