Completed
Push — master ( 4d49f2...b9481e )
by Prateek
05:48 queued 03:41
created

Generate::getStub()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Prateekkarki\Laragen\Commands;
4
5
use Illuminate\Console\Command;
6
use Prateekkarki\Laragen\Generators\Migration as MigrationGenerator;
7
use Prateekkarki\Laragen\Generators\Model as ModelGenerator;
8
use Prateekkarki\Laragen\Models\Module;
9
10
class Generate extends Command
11
{
12
    /**
13
     * The name and signature of the console command.
14
     *
15
     * @var string
16
     */
17
    protected $signature = 'laragen:make';
18
19
    /**
20
     * The console command description.
21
     *
22
     * @var string
23
     */
24
    protected $description = 'Generate code for your project';
25
26
    /**
27
     * Create a new command instance.
28
     *
29
     * @return void
30
     */
31
    public function __construct(
32
        MigrationGenerator $migrationGenerator,
33
        ModelGenerator $modelGenerator
34
    )
35
    {
36
        parent::__construct();
37
        $this->migrationGenerator = $migrationGenerator;
0 ignored issues
show
Bug Best Practice introduced by
The property migrationGenerator does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
38
        $this->modelGenerator = $modelGenerator;
0 ignored issues
show
Bug Best Practice introduced by
The property modelGenerator does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
39
    }
40
41
    /**
42
     * Execute the console command.
43
     *
44
     * @return mixed
45
     */
46
    public function handle()
47
    {
48
        $config = config('laragen');
49
        foreach ($config['modules'] as $moduleName => $moduleArray) {
50
            $moduleArray['name'] = $moduleName;
51
            $module = new Module($moduleArray);
52
            $this->migrationGenerator->generate($module);
53
            $this->modelGenerator->generate($module);
54
        }
55
    }
56
}
57