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 TagController |
||
| 10 | { |
||
| 11 | public function index(Request $request) |
||
| 17 | |||
| 18 | public function create(Request $request) |
||
| 22 | |||
| 23 | View Code Duplication | public function store(Request $request) |
|
| 33 | |||
| 34 | public function show($slug) |
||
| 44 | |||
| 45 | public function edit(Tag $tag) |
||
| 49 | |||
| 50 | View Code Duplication | public function update(Request $request, Tag $tag) |
|
| 60 | |||
| 61 | public function destroy(Tag $tag) |
||
| 67 | } |
||
| 68 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.