SeederCommand::handle()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 2
Bugs 1 Features 1
Metric Value
c 2
b 1
f 1
dl 0
loc 9
ccs 6
cts 6
cp 1
rs 9.6666
cc 3
eloc 5
nc 3
nop 0
crap 3
1
<?php
2
3
namespace agoalofalife\postman\Console;
4
5
use Illuminate\Console\Command;
6
use ModePostEmailSeeder;
7
use StatusesSeeder;
8
9
class SeederCommand extends Command
10
{
11
    protected $seeds = [
12
        ModePostEmailSeeder::class,
13
        StatusesSeeder::class
14
    ];
15
16
    protected $seedersPath = __DIR__.'/../../database/seeds/';
17
18
    /**
19
     * The name and signature of the console command.
20
     *
21
     * @var string
22
     */
23
    protected $signature = 'postman:seed';
24
    /**
25
     * The console command description.
26
     *
27
     * @var string
28
     */
29
    protected $description = 'Fill tables';
30
31
    /**
32
     * Execute the console command.
33
     *
34
     * @return void
35
     */
36 6
    public function handle() : void
37
    {
38 6
        $this->info('Seeding data into the database');
39
40 6
        foreach ($this->seeds as $seed) {
41 6
            if (!class_exists($seed)) {
42 2
                require_once $this->seedersPath . $seed .'.php';
43
            }
44 6
            (new $seed())->run();
45
        }
46 6
    }
47
}
48