Total Complexity | 4 |
Total Lines | 64 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 0 |
1 | <?php |
||
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) |
||
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) |
||
71 |