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 |
||
| 12 | class NotificationController extends Controller |
||
| 13 | { |
||
| 14 | |||
| 15 | use Helpers; |
||
| 16 | |||
| 17 | public function __construct() { |
||
| 19 | |||
| 20 | /** |
||
| 21 | * Display a listing of all notifications |
||
| 22 | * |
||
| 23 | * @return \Illuminate\Http\Response |
||
| 24 | */ |
||
| 25 | public function index(Request $request, $type = null) |
||
| 36 | |||
| 37 | public function update(Request $request, $id, $action) |
||
| 60 | |||
| 61 | /** |
||
| 62 | * Create a new notification |
||
| 63 | * |
||
| 64 | * @return \Illuminate\Http\Response |
||
| 65 | */ |
||
| 66 | public function create(Request $request) |
||
| 81 | |||
| 82 | } |
||
| 83 |
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.