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 |
||
| 31 | class GroupsController extends Controller |
||
| 32 | { |
||
| 33 | use DispatchesJobs; |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Array of sub-menu items. |
||
| 37 | * |
||
| 38 | * @var array |
||
| 39 | */ |
||
| 40 | protected $subMenu = []; |
||
| 41 | |||
| 42 | /** |
||
| 43 | * Creates a new project controller instance. |
||
| 44 | * |
||
| 45 | * @return void |
||
|
|
|||
| 46 | */ |
||
| 47 | public function __construct() |
||
| 69 | |||
| 70 | /** |
||
| 71 | * Shows the project group view. |
||
| 72 | * |
||
| 73 | * @return \Illuminate\View\View |
||
| 74 | */ |
||
| 75 | View Code Duplication | public function index() |
|
| 84 | } |
||
| 85 |
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.