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 PasswordController extends Controller |
||
| 10 | { |
||
| 11 | /* |
||
| 12 | |-------------------------------------------------------------------------- |
||
| 13 | | Password Reset Controller |
||
| 14 | |-------------------------------------------------------------------------- |
||
| 15 | | |
||
| 16 | | This controller is responsible for handling password reset requests |
||
| 17 | | and uses a simple trait to include this behavior. You're free to |
||
| 18 | | explore this trait and override any methods you wish to tweak. |
||
| 19 | | |
||
| 20 | */ |
||
| 21 | |||
| 22 | use ResetsPasswords; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Create a new password controller instance. |
||
| 26 | * |
||
| 27 | * @return void |
||
|
|
|||
| 28 | */ |
||
| 29 | public function __construct() |
||
| 30 | { |
||
| 31 | $this->middleware('guest'); |
||
| 32 | } |
||
| 33 | |||
| 34 | View Code Duplication | public function prePostEmail(Request $request){ |
|
| 45 | |||
| 46 | View Code Duplication | public function prePostReset(Request $request){ |
|
| 57 | |||
| 58 | } |
||
| 59 |
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.