1 | <?php |
||
9 | class GenerateCommand extends Command |
||
10 | { |
||
11 | /** |
||
12 | * The console command name. |
||
13 | * |
||
14 | * @var string |
||
15 | */ |
||
16 | protected $signature = 'admin:generate {name} {--model=} {--O|output}'; |
||
17 | |||
18 | /** |
||
19 | * The console command description. |
||
20 | * |
||
21 | * @var string |
||
22 | */ |
||
23 | protected $description = 'laravel-admin code generator'; |
||
24 | |||
25 | /** |
||
26 | * @var ResourceGenerator |
||
27 | */ |
||
28 | protected $generator; |
||
29 | |||
30 | /** |
||
31 | * The filesystem instance. |
||
32 | * |
||
33 | * @var \Illuminate\Filesystem\Filesystem |
||
34 | */ |
||
35 | protected $files; |
||
36 | |||
37 | /** |
||
38 | * Create a new controller creator command instance. |
||
39 | * |
||
40 | * @param \Illuminate\Filesystem\Filesystem $files |
||
41 | */ |
||
42 | public function __construct(Filesystem $files) |
||
48 | |||
49 | /** |
||
50 | * Execute the console command. |
||
51 | * |
||
52 | * @return void |
||
53 | */ |
||
54 | public function handle() |
||
66 | |||
67 | /** |
||
68 | * @param string $modelName |
||
69 | */ |
||
70 | protected function output($modelName) |
||
78 | |||
79 | /** |
||
80 | * @return bool |
||
81 | */ |
||
82 | protected function generate() |
||
115 | |||
116 | /** |
||
117 | * @param string $name |
||
118 | * @param string $resource |
||
119 | * @return mixed |
||
120 | */ |
||
121 | protected function buildControllerClass($name, $resource) |
||
135 | |||
136 | /** |
||
137 | * @param string $name |
||
138 | * @return mixed |
||
139 | */ |
||
140 | protected function buildResourceClass($name) |
||
164 | |||
165 | /** |
||
166 | * @param string $code |
||
167 | * @return string |
||
168 | */ |
||
169 | protected function indentCodes($code) |
||
175 | |||
176 | /** |
||
177 | * Get the default namespace for the class. |
||
178 | * |
||
179 | * @param string $rootNamespace |
||
180 | * @param string $dir |
||
181 | * |
||
182 | * @return string |
||
183 | */ |
||
184 | protected function getDefaultNamespace($rootNamespace, $dir = 'Controllers') |
||
192 | |||
193 | /** |
||
194 | * Parse the class name and format according to the root namespace. |
||
195 | * |
||
196 | * @param string $name |
||
197 | * @param string $dir |
||
198 | * |
||
199 | * @return string |
||
200 | */ |
||
201 | protected function qualifyClass($name, $dir = 'Controllers') |
||
218 | |||
219 | /** |
||
220 | * Determine if the class already exists. |
||
221 | * |
||
222 | * @param string $rawName |
||
223 | * @return bool |
||
224 | */ |
||
225 | protected function alreadyExists($rawName) |
||
229 | |||
230 | /** |
||
231 | * Get the destination class path. |
||
232 | * |
||
233 | * @param string $name |
||
234 | * @return string |
||
235 | */ |
||
236 | protected function getPath($name) |
||
242 | |||
243 | /** |
||
244 | * Build the directory for the class if necessary. |
||
245 | * |
||
246 | * @param string $path |
||
247 | * @return string |
||
248 | */ |
||
249 | protected function makeDirectory($path) |
||
257 | |||
258 | /** |
||
259 | * Get the full namespace for a given class, without the class name. |
||
260 | * |
||
261 | * @param string $name |
||
262 | * @return string |
||
263 | */ |
||
264 | protected function getNamespace($name) |
||
268 | |||
269 | /** |
||
270 | * @return string |
||
271 | */ |
||
272 | protected function getResourceName() |
||
276 | |||
277 | /** |
||
278 | * @return string |
||
279 | */ |
||
280 | protected function getControllerName() |
||
284 | |||
285 | /** |
||
286 | * Get the root namespace for the class. |
||
287 | * |
||
288 | * @return string |
||
289 | */ |
||
290 | protected function rootNamespace() |
||
294 | } |
||
295 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.