Conditions | 4 |
Paths | 3 |
Total Lines | 22 |
Code Lines | 12 |
Lines | 10 |
Ratio | 45.45 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
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 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.