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 |
||
| 9 | class ResetPasswordController extends Controller |
||
| 10 | { |
||
| 11 | protected $data = []; // the information we send to the view |
||
| 12 | |||
| 13 | /* |
||
| 14 | |-------------------------------------------------------------------------- |
||
| 15 | | Password Reset Controller |
||
| 16 | |-------------------------------------------------------------------------- |
||
| 17 | | |
||
| 18 | | This controller is responsible for handling password reset requests |
||
| 19 | | and uses a simple trait to include this behavior. You're free to |
||
| 20 | | explore this trait and override any methods you wish to tweak. |
||
| 21 | | |
||
| 22 | */ |
||
| 23 | |||
| 24 | use ResetsPasswords; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * Create a new controller instance. |
||
| 28 | * |
||
| 29 | * @return void |
||
|
|
|||
| 30 | */ |
||
| 31 | View Code Duplication | public function __construct() |
|
| 42 | |||
| 43 | public function guard() |
||
| 51 | |||
| 52 | // ------------------------------------------------------- |
||
| 53 | // Laravel overwrites for loading backpack views |
||
| 54 | // ------------------------------------------------------- |
||
| 55 | |||
| 56 | /** |
||
| 57 | * Display the password reset view for the given token. |
||
| 58 | * |
||
| 59 | * If no token is present, display the link request form. |
||
| 60 | * |
||
| 61 | * @param \Illuminate\Http\Request $request |
||
| 62 | * @param string|null $token |
||
| 63 | * |
||
| 64 | * @return \Illuminate\Http\Response |
||
| 65 | */ |
||
| 66 | public function showResetForm(Request $request, $token = null) |
||
| 74 | } |
||
| 75 |
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.