Completed
Push — master ( fc3d6f...f7b1d9 )
by Sergi Tur
28:05
created

src/Console/Username.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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
    use Installable;
14
15
    /**
16
     * The filesystem instance.
17
     *
18
     * @var \Illuminate\Filesystem\Filesystem
19
     */
20
    protected $files;
21
22
    /**
23
     * The name and signature of the console command.
24
     */
25
    protected $signature = 'adminlte:username {--f|force : Force overwrite of files}';
26
27
    /**
28
     * The console command description.
29
     *
30
     * @var string
31
     */
32
    protected $description = 'Changes to login and register with username';
33
34
    /**
35
     * Force overwrite of files.
36
     *
37
     * @var bool
38
     */
39
    protected $force = false;
40
41
    /**
42
     * Create a new command instance.
43
     *
44
     * @param \Illuminate\Filesystem\Filesystem $files
45
     *
46
     */
47
    public function __construct(Filesystem $files)
48
    {
49
        parent::__construct();
50
        $this->files = $files;
51
    }
52
53
    /**
54
     * Execute the console command.
55
     */
56
    public function handle()
57
    {
58
        $this->processOptions();
59
        $this->publishAuthConfigFile();
60
        $this->publishUserClass();
61
        $this->runMigration();
62
    }
63
64
    /**
65
     * Install auth config file.
66
     */
67
    private function publishAuthConfigFile()
68
    {
69
        $this->install(\Acacha\AdminLTETemplateLaravel\Facades\AdminLTE::authConfig());
70
    }
71
72
    /**
73
     * Publish User class.
74
     */
75
    private function publishUserClass()
76
    {
77
        $this->install(\Acacha\AdminLTETemplateLaravel\Facades\AdminLTE::userClass());
78
    }
79
80
    /**
81
     * Run migration.
82
     */
83
    private function runMigration()
84
    {
85
        $this->info('Installing doctrine/dbal');
86
        passthru('composer require doctrine/dbal');
87
        $this->info('Running php artisan migrate');
88
        passthru('php artisan migrate');
89
    }
90
91
    /**
92
     * Process options before running command.
93
     */
94
    private function processOptions()
95
    {
96
        $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...
97
    }
98
}
99