GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

MakeUserCommand   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 50
Duplicated Lines 20 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
c 0
b 0
f 0
lcom 1
cbo 1
dl 10
loc 50
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A fire() 10 22 4

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace LaravelFlare\Flare\Console\Commands;
4
5
use Illuminate\Console\Command;
6
7
class MakeUserCommand extends Command
8
{
9
    /**
10
     * The console command name.
11
     *
12
     * @var string
13
     */
14
    protected $name = 'make:user';
15
16
    /**
17
     * The console command description.
18
     *
19
     * @var string
20
     */
21
    protected $description = 'Creates a new user';
22
23
    /**
24
     * __construct.
25
     */
26
    public function __construct()
27
    {
28
        parent::__construct();
29
    }
30
31
    /**
32
     * Run the command.
33
     */
34
    public function fire()
35
    {
36
        $name = $this->ask('Please provide a username (defaults to admin)', 'admin');
37
        $email = $this->ask('Please provide your email (defaults to [email protected])', '[email protected]');
38
        $password = $this->ask('Please provide a password (defaults to password)', 'password');
39
40
        $authModel = config('auth.model');
41
42 View Code Duplication
        if (!get_class($authProvider = \Auth::getProvider()) === \Illuminate\Auth\EloquentUserProvider::class || !($authModel = $authProvider->getModel())) {
43
            $this->warn('To create a new admin user you must use Eloquent as your Auth Provider');
44
45
            return;
46
        }
47
48 View Code Duplication
        if ((new $authModel())->create(['name' => $name, 'email' => $email, 'password' => bcrypt($password)])) {
49
            $this->info('All done!');
50
51
            return;
52
        }
53
54
        $this->error('Something went wrong... Please try again.');
55
    }
56
}
57