| Conditions | 5 |
| Paths | 16 |
| Total Lines | 28 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 31 | public function handle() |
||
| 32 | { |
||
| 33 | $this->info('Creating a new user'); |
||
| 34 | |||
| 35 | if (!$name = $this->option('name')) { |
||
| 36 | $name = $this->ask('Name'); |
||
| 37 | } |
||
| 38 | |||
| 39 | if (!$email = $this->option('email')) { |
||
| 40 | $email = $this->ask('Email'); |
||
| 41 | } |
||
| 42 | |||
| 43 | if (!$password = $this->option('password')) { |
||
| 44 | $password = $this->secret('Password'); |
||
| 45 | } |
||
| 46 | |||
| 47 | $auth = config('backpack.base.user_model_fqn', 'App\User'); |
||
| 48 | $user = new $auth(); |
||
| 49 | $user->name = $name; |
||
| 50 | $user->email = $email; |
||
| 51 | $user->password = bcrypt($password); |
||
|
|
|||
| 52 | |||
| 53 | if ($user->save()) { |
||
| 54 | $this->info('Successfully created new user'); |
||
| 55 | } else { |
||
| 56 | $this->error('Something went wrong trying to save your user'); |
||
| 57 | } |
||
| 58 | } |
||
| 59 | } |
||
| 60 |
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.