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 |
||
| 18 | class MomentController extends Controller |
||
| 19 | { |
||
| 20 | /** |
||
| 21 | * Display a listing of the resource. |
||
| 22 | * |
||
| 23 | * @return \Illuminate\Http\Response |
||
| 24 | */ |
||
| 25 | |||
| 26 | /** |
||
| 27 | * Array of sub-menu items. |
||
| 28 | * |
||
| 29 | * @var array |
||
| 30 | */ |
||
| 31 | protected $subMenu = []; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * Creates a new moment controller instance. |
||
| 35 | * |
||
| 36 | * @return void |
||
|
|
|||
| 37 | */ |
||
| 38 | View Code Duplication | public function __construct() |
|
| 60 | |||
| 61 | public function index() |
||
| 71 | } |
||
| 72 |
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.