These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Nwidart\Modules\Commands; |
||
4 | |||
5 | use Illuminate\Support\Str; |
||
6 | use Nwidart\Modules\Support\Config\GenerateConfigReader; |
||
7 | use Nwidart\Modules\Support\Stub; |
||
8 | use Nwidart\Modules\Traits\ModuleCommandTrait; |
||
9 | use Symfony\Component\Console\Input\InputArgument; |
||
10 | |||
11 | View Code Duplication | class MailMakeCommand extends GeneratorCommand |
|
12 | { |
||
13 | use ModuleCommandTrait; |
||
14 | |||
15 | /** |
||
16 | * The console command name. |
||
17 | * |
||
18 | * @var string |
||
19 | */ |
||
20 | protected $name = 'module:make-mail'; |
||
21 | |||
22 | /** |
||
23 | * The console command description. |
||
24 | * |
||
25 | * @var string |
||
26 | */ |
||
27 | protected $description = 'Create a new email class for the specified module'; |
||
28 | |||
29 | protected $argumentName = 'name'; |
||
30 | |||
31 | 4 | public function getDefaultNamespace() : string |
|
32 | { |
||
33 | 4 | $module = $this->laravel['modules']; |
|
34 | |||
35 | 4 | return $module->config('paths.generator.emails.namespace') ?: $module->config('paths.generator.emails.path', 'Emails'); |
|
36 | } |
||
37 | |||
38 | /** |
||
39 | * Get the console command arguments. |
||
40 | * |
||
41 | * @return array |
||
42 | */ |
||
43 | 120 | protected function getArguments() |
|
44 | { |
||
45 | return [ |
||
46 | 120 | ['name', InputArgument::REQUIRED, 'The name of the mailable.'], |
|
47 | ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], |
||
48 | ]; |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * Get template contents. |
||
53 | * |
||
54 | * @return string |
||
55 | */ |
||
56 | 4 | protected function getTemplateContents() |
|
57 | { |
||
58 | 4 | $module = $this->laravel['modules']->findOrFail($this->getModuleName()); |
|
59 | |||
60 | 4 | return (new Stub('/mail.stub', [ |
|
61 | 4 | 'NAMESPACE' => $this->getClassNamespace($module), |
|
62 | 4 | 'CLASS' => $this->getClass(), |
|
63 | 4 | ]))->render(); |
|
64 | } |
||
65 | |||
66 | /** |
||
67 | * Get the destination file path. |
||
68 | * |
||
69 | * @return string |
||
70 | */ |
||
71 | 4 | protected function getDestinationFilePath() |
|
72 | { |
||
73 | 4 | $path = $this->laravel['modules']->getModulePath($this->getModuleName()); |
|
74 | |||
75 | 4 | $mailPath = GenerateConfigReader::read('emails'); |
|
76 | |||
77 | 4 | return $path . $mailPath->getPath() . '/' . $this->getFileName() . '.php'; |
|
78 | } |
||
79 | |||
80 | /** |
||
81 | * @return string |
||
82 | */ |
||
83 | 4 | private function getFileName() |
|
84 | { |
||
85 | 4 | return Str::studly($this->argument('name')); |
|
0 ignored issues
–
show
|
|||
86 | } |
||
87 | } |
||
88 |
This check looks at variables that are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.