GenerateExceptionCommand   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
eloc 11
dl 0
loc 64
ccs 0
cts 12
cp 0
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A buildClass() 0 6 1
A getStub() 0 3 1
A getPath() 0 6 1
A getDefaultNamespace() 0 3 1
1
<?php
2
3
namespace LaravelModulize\Console\Commands;
4
5
class GenerateExceptionCommand extends BaseGeneratorCommand
6
{
7
    /**
8
     * The name and signature of the console command.
9
     *
10
     * @var string
11
     */
12
    protected $signature = 'modulize:make:exception {module} {name}';
13
14
    /**
15
     * The console command description.
16
     *
17
     * @var string
18
     */
19
    protected $description = 'Generate a exception only thrown by given module';
20
21
    /**
22
     * Get the stub file for the generator.
23
     *
24
     * @return string
25
     */
26
    protected function getStub(): string
27
    {
28
        return __DIR__ . '/stubs/Exception.stub';
29
    }
30
31
        /**
32
     * Get the destination class path.
33
     *
34
     * @param  string  $name
35
     * @return string
36
     */
37
    protected function getPath($name): string
38
    {
39
        $name = str_replace(
40
            ['\\', '/'], '', $this->argument('name')
41
        );
42
        return $this->repository->exceptionPath($this->module) . "/{$name}.php";
43
    }
44
45
        /**
46
     * Build the class with the given name.
47
     *
48
     * @param  string  $name
49
     * @return string
50
     */
51
    protected function buildClass($name)
52
    {
53
        $model = $this->argument('name');
54
55
        return str_replace(
56
            'DummyException', $model, parent::buildClass($name)
57
        );
58
    }
59
60
    /**
61
     * Get the default namespace for the class.
62
     *
63
     * @param  string  $rootNamespace
64
     * @return string
65
     */
66
    protected function getDefaultNamespace($rootNamespace)
67
    {
68
        return $this->repository->getModuleNamespace($this->module);
69
    }
70
}
71