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