Completed
Push — master ( a64245...e0b49d )
by Manel
58:10 queued 28:11
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') can also be of type string or array. However, the property $force is declared as type boolean. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
97
    }
98
}
99