SeederCommand   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 37
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 17 1
A getSeederName() 0 7 1
1
<?php namespace Wn\Generators\Commands;
2
3
4
class SeederCommand extends BaseCommand {
5
6
	protected $signature = 'wn:seeder
7
        {model : full qualified name of the model.}
8
        {--count=10 : number of elements to add in database.}
9
        {--force= : override the existing files}
10
    ';
11
12
	protected $description = 'Generates a seeder';
13
14
    public function handle()
15
    {
16
        $model = $this->argument('model');
17
        $name = $this->getSeederName($model);
18
        $file = "./database/seeds/{$name}.php";
19
20
        $content = $this->getTemplate('seeder')
21
            ->with([
22
                'model' => $model,
23
                'name' => $name,
24
                'count' => $this->option('count')
25
            ])
26
            ->get();
27
28
29
        $this->save($content, $file, $name);
30
    }
31
32
    protected function getSeederName($name)
33
    {
34
        $name = explode("\\", $name);
35
        $name = ucwords(\Illuminate\Support\Str::plural($name[count($name) - 1]));
36
        $name = $name . 'TableSeeder';
37
        return $name;
38
    }
39
40
}
41