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 | final class NotificationMakeCommand extends GeneratorCommand |
|
12 | { |
||
13 | use ModuleCommandTrait; |
||
14 | |||
15 | /** |
||
16 | * The console command name. |
||
17 | * |
||
18 | * @var string |
||
19 | */ |
||
20 | protected $name = 'module:make-notification'; |
||
21 | |||
22 | protected $argumentName = 'name'; |
||
23 | |||
24 | /** |
||
25 | * The console command description. |
||
26 | * |
||
27 | * @var string |
||
28 | */ |
||
29 | protected $description = 'Create a new notification class for the specified module.'; |
||
30 | |||
31 | 4 | public function getDefaultNamespace() : string |
|
32 | { |
||
33 | 4 | $module = $this->laravel['modules']; |
|
34 | |||
35 | 4 | return $module->config('paths.generator.notifications.namespace') ?: $module->config('paths.generator.notifications.path', 'Notifications'); |
|
36 | } |
||
37 | |||
38 | /** |
||
39 | * Get template contents. |
||
40 | * |
||
41 | * @return string |
||
42 | */ |
||
43 | 4 | protected function getTemplateContents() |
|
44 | { |
||
45 | 4 | $module = $this->laravel['modules']->findOrFail($this->getModuleName()); |
|
46 | |||
47 | 4 | return (new Stub('/notification.stub', [ |
|
48 | 4 | 'NAMESPACE' => $this->getClassNamespace($module), |
|
49 | 4 | 'CLASS' => $this->getClass(), |
|
50 | 4 | ]))->render(); |
|
51 | } |
||
52 | |||
53 | /** |
||
54 | * Get the destination file path. |
||
55 | * |
||
56 | * @return string |
||
57 | */ |
||
58 | 4 | protected function getDestinationFilePath() |
|
59 | { |
||
60 | 4 | $path = $this->laravel['modules']->getModulePath($this->getModuleName()); |
|
61 | |||
62 | 4 | $notificationPath = GenerateConfigReader::read('notifications'); |
|
63 | |||
64 | 4 | return $path . $notificationPath->getPath() . '/' . $this->getFileName() . '.php'; |
|
65 | } |
||
66 | |||
67 | /** |
||
68 | * @return string |
||
69 | */ |
||
70 | 4 | private function getFileName() |
|
71 | { |
||
72 | 4 | return Str::studly($this->argument('name')); |
|
0 ignored issues
–
show
|
|||
73 | } |
||
74 | |||
75 | /** |
||
76 | * Get the console command arguments. |
||
77 | * |
||
78 | * @return array |
||
79 | */ |
||
80 | 120 | protected function getArguments() |
|
81 | { |
||
82 | return [ |
||
83 | 120 | ['name', InputArgument::REQUIRED, 'The name of the notification class.'], |
|
84 | ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], |
||
85 | ]; |
||
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.