Completed
Push — master ( bb5866...53bf7a )
by Sergi Tur
04:03
created

Username::handle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
3
namespace Acacha\AdminLTETemplateLaravel\Console;
4
5
use Illuminate\Console\Command;
6
use Illuminate\Filesystem\Filesystem;
7
8
/**
9
 * Class Username.
10
 */
11
class Username extends Command
12
{
13
14
    use Installable;
15
16
    /**
17
     * The filesystem instance.
18
     *
19
     * @var \Illuminate\Filesystem\Filesystem
20
     */
21
    protected $files;
22
23
    /**
24
     * The name and signature of the console command.
25
     */
26
    protected $signature = 'adminlte:username {--f|force : Force overwrite of files}';
27
28
    /**
29
     * The console command description.
30
     *
31
     * @var string
32
     */
33
    protected $description = 'Changes to login and register with username';
34
35
    /**
36
     * Force overwrite of files.
37
     *
38
     * @var bool
39
     */
40
    protected $force = false;
41
42
    /**
43
     * Create a new command instance.
44
     *
45
     * @param \Illuminate\Filesystem\Filesystem $files
46
     *
47
     */
48
    public function __construct(Filesystem $files)
49
    {
50
        parent::__construct();
51
        $this->files = $files;
52
    }
53
54
    /**
55
     * Execute the console command.
56
     */
57
    public function handle()
58
    {
59
        $this->processOptions();
60
        $this->publishAuthConfigFile();
61
        $this->publishUserClass();
62
        $this->runMigration();
63
    }
64
65
    /**
66
     * Install auth config file.
67
     */
68
    private function publishAuthConfigFile()
69
    {
70
        $this->install(\Acacha\AdminLTETemplateLaravel\Facades\AdminLTE::authConfig());
71
    }
72
73
    /**
74
     * Publish User class.
75
     */
76
    private function publishUserClass() {
77
        $this->install(\Acacha\AdminLTETemplateLaravel\Facades\AdminLTE::userClass());
78
    }
79
80
    /**
81
     * Run migration.
82
     */
83
    private function runMigration() {
84
        $this->info('Installing doctrine/dbal');
85
        passthru('composer require doctrine/dbal');
86
        $this->info('Running php artisan migrate');
87
        passthru('php artisan migrate');
88
    }
89
90
    /**
91
     * Process options before running command.
92
     */
93
    private function processOptions()
94
    {
95
        $this->force = $this->option('force');
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->option('force') of type string or array is incompatible with the declared type boolean of property $force.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
96
    }
97
}
98