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 CategoryController |
||
10 | { |
||
11 | public function index(Request $request) |
||
17 | |||
18 | public function create(Request $request) |
||
22 | |||
23 | public function store(Request $request) |
||
33 | |||
34 | View Code Duplication | public function show(Category $category) |
|
41 | |||
42 | public function edit(Category $category) |
||
46 | |||
47 | View Code Duplication | public function update(Request $request, Category $category) |
|
57 | |||
58 | public function destroy(Category $category) |
||
64 | } |
||
65 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.