ProjectsSeederCommand::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Chriscreates\Projects\Commands;
4
5
use Chriscreates\Projects\Seeds\ProjectsSeeder;
6
use Illuminate\Console\Command;
7
8
class ProjectsSeederCommand extends Command
9
{
10
    /**
11
     * The name and signature of the console command.
12
     *
13
     * @var string
14
     */
15
    protected $signature = 'projects:seed';
16
17
    /**
18
     * The console command description.
19
     *
20
     * @var string
21
     */
22
    protected $description = 'Laravel Artisan Command to call the repository seeds.';
23
24
    /**
25
     * Create a new command instance.
26
     *
27
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
28
     */
29
    public function __construct()
30
    {
31
        parent::__construct();
32
    }
33
34
    /**
35
     * Execute the console command.
36
     *
37
     * @return mixed
38
     */
39
    public function handle()
40
    {
41
        if ( ! projects_config_published()) {
42
            $this->error('Config has not been published.');
43
44
            if ( ! $this->confirm('Would you like to publish the config?')) {
45
                return;
46
            }
47
48
            $this->call('projects:publish');
49
        }
50
51
        $this->line('Starting project seeds.');
52
53
        set_time_limit(0);
54
55
        do {
56
            if (projects_config_published()) {
57
                $this->callSilent('config:cache');
58
                $this->call(ProjectsSeeder::class);
59
                $this->callSilent('config:clear');
60
61
                break;
62
            }
63
        } while (true);
64
65
        $this->info('Finished project seeds.');
66
    }
67
}
68