These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /* |
||
4 | * NOTICE OF LICENSE |
||
5 | * |
||
6 | * Part of the Rinvex Fort Package. |
||
7 | * |
||
8 | * This source file is subject to The MIT License (MIT) |
||
9 | * that is bundled with this package in the LICENSE file. |
||
10 | * |
||
11 | * Package: Rinvex Fort Package |
||
12 | * License: The MIT License (MIT) |
||
13 | * Link: https://rinvex.com |
||
14 | */ |
||
15 | |||
16 | namespace Rinvex\Fort\Console\Commands; |
||
17 | |||
18 | use Illuminate\Console\Command; |
||
19 | use Illuminate\Support\Facades\Lang; |
||
20 | |||
21 | class UserRemindCommand extends Command |
||
22 | { |
||
23 | /** |
||
24 | * The name and signature of the console command. |
||
25 | * |
||
26 | * @var string |
||
27 | */ |
||
28 | protected $signature = 'fort:user:remind |
||
29 | {user? : The user identifier} |
||
30 | {action? : The action to remind user of} |
||
31 | {broker? : The name of the password broker}'; |
||
32 | |||
33 | /** |
||
34 | * The console command description. |
||
35 | * |
||
36 | * @var string |
||
37 | */ |
||
38 | protected $description = 'Remind user to take action (reset password, verify email).'; |
||
39 | |||
40 | /** |
||
41 | * Execute the console command. |
||
42 | * |
||
43 | * @return void |
||
44 | */ |
||
45 | public function handle() |
||
46 | { |
||
47 | $userField = $this->argument('user') ?: $this->ask(Lang::get('rinvex.fort::artisan.user.identifier')); |
||
48 | |||
49 | if (intval($userField)) { |
||
50 | $user = $this->laravel['rinvex.fort.user']->find($userField); |
||
51 | } elseif (filter_var($userField, FILTER_VALIDATE_EMAIL)) { |
||
52 | $user = $this->laravel['rinvex.fort.user']->findWhere(['email' => $userField])->first(); |
||
53 | } else { |
||
54 | $user = $this->laravel['rinvex.fort.user']->findWhere(['username' => $userField])->first(); |
||
55 | } |
||
56 | |||
57 | if (! $user) { |
||
58 | return $this->error(Lang::get('rinvex.fort::artisan.user.invalid', ['field' => $userField])); |
||
59 | } |
||
60 | |||
61 | $actionField = $this->argument('action') ?: $this->anticipate(Lang::get('rinvex.fort::artisan.user.action'), ['resetpassword', 'verification']); |
||
62 | |||
63 | switch ($actionField) { |
||
64 | case 'resetpassword': |
||
65 | $this->laravel['rinvex.fort.resetter']->broker($this->argument('broker'))->sendResetLink(['email' => $user->email]); |
||
66 | |||
67 | return $this->info(Lang::get('rinvex.fort::artisan.user.resetpassword')); |
||
68 | break; |
||
0 ignored issues
–
show
|
|||
69 | |||
70 | case 'verification': |
||
71 | $this->laravel['rinvex.fort.verifier']->broker($this->argument('broker'))->sendVerificationLink(['email' => $user->email]); |
||
72 | |||
73 | return $this->info(Lang::get('rinvex.fort::artisan.user.verification')); |
||
74 | break; |
||
75 | } |
||
76 | |||
77 | return $this->error(Lang::get('rinvex.fort::artisan.user.invalidaction')); |
||
78 | } |
||
79 | } |
||
80 |
The break statement is not necessary if it is preceded for example by a return statement:
If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.