HiveGeneratorCommand   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Importance

Changes 4
Bugs 1 Features 3
Metric Value
wmc 7
c 4
b 1
f 3
lcom 2
cbo 1
dl 0
loc 38
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getPath() 0 7 1
A getStub() 0 4 1
A fire() 0 13 4
A getArguments() 0 6 1
1
<?php
2
3
namespace R\Hive\Commands;
4
5
use Illuminate\Console\GeneratorCommand;
6
use Symfony\Component\Console\Input\InputArgument;
7
8
class HiveGeneratorCommand extends GeneratorCommand
9
{
10
    protected $compound = null;
11
12
    protected function getPath($name)
13
    {
14
        $name = str_replace($this->laravel->getNamespace(), '', $name);
0 ignored issues
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...
15
16
        // Add the class type to the file name.
17
        return $this->laravel['path'].'/'.str_replace('\\', '/', $name).$this->type.'.php';
18
    }
19
20
    protected function getStub()
21
    {
22
        return;
23
    }
24
25
    public function fire()
26
    {
27
        if ($this->compound !== null) {
28
            if (parent::fire() !== false) {
29
                if ($this->option($this->compound)) {
30
                    $name = $this->argument('name');
31
                    $this->call("hive:{$this->compound}", ['name' => $name]);
32
                }
33
            }
34
        } else {
35
            parent::fire();
36
        }
37
    }
38
39
    protected function getArguments()
40
    {
41
        return [
42
            ['name', InputArgument::REQUIRED, 'The name of the instance type being referenced, eg: Book.'],
43
        ];
44
    }
45
}
46