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 |
||
| 19 | class ProjectController extends Controller |
||
| 20 | { |
||
| 21 | use DispatchesJobs; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * Array of sub-menu items. |
||
| 25 | * |
||
| 26 | * @var array |
||
| 27 | */ |
||
| 28 | protected $subMenu = []; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * Creates a new project controller instance. |
||
| 32 | * |
||
| 33 | * @return void |
||
|
|
|||
| 34 | */ |
||
| 35 | public function __construct() |
||
| 63 | |||
| 64 | /** |
||
| 65 | * Shows the projects view. |
||
| 66 | * |
||
| 67 | * @return \Illuminate\View\View |
||
| 68 | */ |
||
| 69 | View Code Duplication | public function indexAction() |
|
| 79 | |||
| 80 | /** |
||
| 81 | * Shows the starred projects view. |
||
| 82 | * |
||
| 83 | * @return \Illuminate\View\View |
||
| 84 | */ |
||
| 85 | public function starredAction() |
||
| 97 | } |
||
| 98 |
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.