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 |
||
| 11 | class ResetPasswordController extends Controller |
||
| 12 | { |
||
| 13 | protected $data = []; // the information we send to the view |
||
| 14 | |||
| 15 | /* |
||
| 16 | |-------------------------------------------------------------------------- |
||
| 17 | | Password Reset Controller |
||
| 18 | |-------------------------------------------------------------------------- |
||
| 19 | | |
||
| 20 | | This controller is responsible for handling password reset requests |
||
| 21 | | and uses a simple trait to include this behavior. You're free to |
||
| 22 | | explore this trait and override any methods you wish to tweak. |
||
| 23 | | |
||
| 24 | */ |
||
| 25 | |||
| 26 | use ResetsPasswords; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Create a new controller instance. |
||
| 30 | * |
||
| 31 | * @return void |
||
|
|
|||
| 32 | */ |
||
| 33 | View Code Duplication | public function __construct() |
|
| 43 | |||
| 44 | // ------------------------------------------------------- |
||
| 45 | // Laravel overwrites for loading backpack views |
||
| 46 | // ------------------------------------------------------- |
||
| 47 | |||
| 48 | /** |
||
| 49 | * Display the password reset view for the given token. |
||
| 50 | * |
||
| 51 | * If no token is present, display the link request form. |
||
| 52 | * |
||
| 53 | * @param \Illuminate\Http\Request $request |
||
| 54 | * @param string|null $token |
||
| 55 | * |
||
| 56 | * @return \Illuminate\Http\Response |
||
| 57 | */ |
||
| 58 | public function showResetForm(Request $request, $token = null) |
||
| 66 | |||
| 67 | public function broker() |
||
| 74 | |||
| 75 | protected function guard() |
||
| 82 | } |
||
| 83 |
Adding a
@returnannotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.