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 |
||
| 13 | class Authenticate |
||
| 14 | { |
||
| 15 | /** |
||
| 16 | * The Guard implementation. |
||
| 17 | * |
||
| 18 | * @var Guard |
||
| 19 | */ |
||
| 20 | protected $auth; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * Create a new filter instance. |
||
| 24 | * |
||
| 25 | * @param Guard $auth |
||
| 26 | * |
||
| 27 | * @return void |
||
|
|
|||
| 28 | */ |
||
| 29 | public function __construct(Guard $auth) |
||
| 33 | |||
| 34 | /** |
||
| 35 | * Handle an incoming request. |
||
| 36 | * |
||
| 37 | * @param \Illuminate\Http\Request $request |
||
| 38 | * @param \Closure $next |
||
| 39 | * |
||
| 40 | * @return mixed |
||
| 41 | */ |
||
| 42 | public function handle($request, Closure $next) |
||
| 56 | } |
||
| 57 |
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.