Conditions | 8 |
Paths | 24 |
Total Lines | 56 |
Code Lines | 29 |
Lines | 0 |
Ratio | 0 % |
Changes | 10 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
29 | public function handle() |
||
30 | { |
||
31 | $laragen = LaragenOptions::getInstance(); |
||
32 | $modules = $laragen->getModules(); |
||
33 | $generators = $laragen->getGenerators(); |
||
34 | $generatedFiles = []; |
||
35 | $fileSystem = new FileSystem(); |
||
36 | |||
37 | $this->line(" |
||
38 | ██▓ ▄▄▄ ██▀███ ▄▄▄ ▄████ ▓█████ ███▄ █ |
||
39 | ▓██▒ ▒████▄ ▓██ ▒ ██▒▒████▄ ██▒ ▀█▒▓█ ▀ ██ ▀█ █ |
||
40 | ▒██░ ▒██ ▀█▄ ▓██ ░▄█ ▒▒██ ▀█▄ ▒██░▄▄▄░▒███ ▓██ ▀█ ██▒ |
||
41 | ▒██░ ░██▄▄▄▄██ ▒██▀▀█▄ ░██▄▄▄▄██ ░▓█ ██▓▒▓█ ▄ ▓██▒ ▐▌██▒ |
||
42 | ░██████▒▓█ ▓██▒░██▓ ▒██▒ ▓█ ▓██▒░▒▓███▀▒░▒████▒▒██░ ▓██░ |
||
43 | ░ ▒░▓ ░▒▒ ▓▒█░░ ▒▓ ░▒▓░ ▒▒ ▓▒█░ ░▒ ▒ ░░ ▒░ ░░ ▒░ ▒ ▒ |
||
44 | ░ ░ ▒ ░ ▒ ▒▒ ░ ░▒ ░ ▒░ ▒ ▒▒ ░ ░ ░ ░ ░ ░░ ░░ ░ ▒░ |
||
45 | ░ ░ ░ ▒ ░░ ░ ░ ▒ ░ ░ ░ ░ ░ ░ ░ |
||
46 | ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ |
||
47 | "); |
||
48 | |||
49 | $this->line("Cleaning code directory ..."); |
||
50 | |||
51 | foreach ([base_path('laragen/app'), base_path('laragen/database')] as $dir) { |
||
52 | if(file_exists($dir)){ |
||
53 | $fileSystem->removeDir($dir); |
||
54 | } |
||
55 | } |
||
56 | |||
57 | $this->line("Generating code..."); |
||
58 | $bar = $this->output->createProgressBar(count($modules) * count($generators)); |
||
59 | $bar->setOverwrite(true); |
||
60 | $bar->start(); |
||
61 | |||
62 | foreach ($modules as $module) { |
||
63 | |||
64 | foreach ($generators as $generator) { |
||
65 | $itemGenerator = new $generator($module); |
||
66 | $returnedFiles = $itemGenerator->generate(); |
||
67 | |||
68 | if (!is_array($returnedFiles)) |
||
69 | $generatedFiles[] = $returnedFiles; |
||
70 | else |
||
71 | $generatedFiles = array_merge($generatedFiles, $returnedFiles); |
||
72 | |||
73 | $bar->advance(); |
||
74 | } |
||
75 | } |
||
76 | $bar->finish(); |
||
77 | |||
78 | $this->line("\n"); |
||
79 | |||
80 | foreach ($generatedFiles as $key => $file) { |
||
81 | \Log::info("Generated file: ".str_replace(base_path()."\\", "", $file)); |
||
82 | } |
||
83 | $this->info((isset($key) ? ++$key : 0)." files generated. Check log for details."); |
||
84 | $this->info("Cheers!!!"); |
||
85 | } |
||
87 |