GenerateExceptionCommand::getStub()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
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