Completed
Push — master ( b9481e...fee819 )
by Prateek
04:31 queued 02:08
created

Generate::handle()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 9
nc 3
nop 0
dl 0
loc 14
rs 9.9666
c 0
b 0
f 0
1
<?php
2
3
namespace Prateekkarki\Laragen\Commands;
4
5
use Illuminate\Console\Command;
6
use Prateekkarki\Laragen\Models\Module;
7
8
class Generate extends Command
9
{
10
    /**
11
     * The name and signature of the console command.
12
     *
13
     * @var string
14
     */
15
    protected $signature = 'laragen:make';
16
17
    /**
18
     * The console command description.
19
     *
20
     * @var string
21
     */
22
    protected $description = 'Generate code for your project';
23
24
    /**
25
     * Execute the console command.
26
     *
27
     * @return mixed
28
     */
29
    public function handle()
30
    {
31
        $config = config('laragen');
32
        foreach ($config['modules'] as $moduleName => $moduleArray) {
33
            $moduleArray['name'] = $moduleName;
34
            $module = new Module($moduleArray);
35
36
            // ToDo: to be loaded dynamically
37
            $itemsToGenerate = ['Migration', 'Controller', 'Model'];
38
39
            foreach ($itemsToGenerate as $item) {
40
                $generator = "\\Prateekkarki\\Laragen\\Generators\\{$item}";
41
                $itemGenerator = new $generator($module);
42
                $itemGenerator->generate();
43
            }
44
        }
45
    }
46
}
47