GeneratorCommand   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 33
rs 10
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A alreadyExists() 0 4 2
A getDefaultNamespace() 0 8 3
1
<?php
2
3
4
namespace Zebrainsteam\LaravelRepos\Console;
5
6
use Illuminate\Console\GeneratorCommand as Generator;
7
8
abstract class GeneratorCommand extends Generator
9
{
10
    /**
11
     * @var string
12
     */
13
    protected $defaultNamespacePrefix = '';
14
15
    /**
16
     * Determine if the class already exists.
17
     *
18
     * @param  string  $rawName
19
     * @return bool
20
     */
21
    protected function alreadyExists($rawName)
22
    {
23
        return class_exists($rawName) ||
24
            $this->files->exists($this->getPath($this->qualifyClass($rawName)));
25
    }
26
27
    /**
28
     * Get the default namespace for the class.
29
     *
30
     * @param string $rootNamespace
31
     * @return string
32
     */
33
    protected function getDefaultNamespace($rootNamespace)
34
    {
35
        $defaultNamespace = $rootNamespace;
36
        if ($this->getNameInput()[0] != '/' && !empty($this->defaultNamespacePrefix)) {
37
            $defaultNamespace .= '\\' . $this->defaultNamespacePrefix;
38
        }
39
40
        return $defaultNamespace;
41
    }
42
}
43