Seed   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 28
rs 10
c 0
b 0
f 0
wmc 6

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 18 6
1
<?php
2
3
namespace Thinktomorrow\Chief\App\Console;
4
5
class Seed extends BaseCommand
6
{
7
    protected $signature = 'chief:seed
8
                            {seeder=DatabaseSeeder : the classname of the seeder. }
9
                            {--force}';
10
    protected $description = 'This will run the seeders to inject new data into your project database.';
11
12
    /**
13
     * @return void
14
     */
15
    public function handle()
16
    {
17
        if (app()->environment() != 'local' && ! $this->option('force')) {
0 ignored issues
show
introduced by
The method environment() does not exist on Illuminate\Container\Container. Are you sure you never get this type here, but always one of the subclasses? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

17
        if (app()->/** @scrutinizer ignore-call */ environment() != 'local' && ! $this->option('force')) {
Loading history...
18
            throw new \Exception('You can only run the seeder in the local environment since this will inject a ton of default data');
19
        }
20
21
        if (app()->environment() != 'local' && $this->option('force')) {
22
            if (! $this->confirm('You are about to inject default seeding data in the ' . app()->environment() . ' database! Are you sure?')) {
23
                $this->info('You are welcome. I have just saved your job.');
24
25
                return;
26
            }
27
        }
28
29
        $seederClass = $this->argument('seeder');
30
        app($seederClass)->run();
0 ignored issues
show
Bug introduced by
It seems like $seederClass can also be of type array; however, parameter $abstract of app() does only seem to accept null|string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

30
        app(/** @scrutinizer ignore-type */ $seederClass)->run();
Loading history...
31
32
        $this->info($seederClass . ' has run successfully.');
33
    }
34
}
35