Conditions | 6 |
Paths | 32 |
Total Lines | 32 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
32 | public function handle() |
||
33 | { |
||
34 | $this->info('Creating a new user'); |
||
35 | |||
36 | if (!$name = $this->option('name')) { |
||
37 | $name = $this->ask('Name'); |
||
38 | } |
||
39 | |||
40 | if (!$email = $this->option('email')) { |
||
41 | $email = $this->ask('Email'); |
||
42 | } |
||
43 | |||
44 | if (!$password = $this->option('password')) { |
||
45 | $password = $this->secret('Password'); |
||
46 | } |
||
47 | |||
48 | if ($this->option('encrypt')) { |
||
49 | $password = bcrypt($password); |
||
|
|||
50 | } |
||
51 | |||
52 | $auth = config('backpack.base.user_model_fqn', 'App\User'); |
||
53 | $user = new $auth(); |
||
54 | $user->name = $name; |
||
55 | $user->email = $email; |
||
56 | $user->password = $password; |
||
57 | |||
58 | if ($user->save()) { |
||
59 | $this->info('Successfully created new user'); |
||
60 | } else { |
||
61 | $this->error('Something went wrong trying to save your user'); |
||
62 | } |
||
63 | } |
||
64 | } |
||
65 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.