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 |
||
| 23 | class JenisSekolahController extends Controller |
||
| 24 | { |
||
| 25 | protected $jenis_sekolah; |
||
| 26 | protected $user; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Create a new controller instance. |
||
| 30 | * |
||
| 31 | * @return void |
||
|
|
|||
| 32 | */ |
||
| 33 | public function __construct() |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Display a listing of the resource. |
||
| 41 | * |
||
| 42 | * @return \Illuminate\Http\Response |
||
| 43 | */ |
||
| 44 | public function index(Request $request) |
||
| 69 | |||
| 70 | /** |
||
| 71 | * Display a listing of the resource. |
||
| 72 | * |
||
| 73 | * @return \Illuminate\Http\Response |
||
| 74 | */ |
||
| 75 | View Code Duplication | public function get() |
|
| 90 | |||
| 91 | /** |
||
| 92 | * Show the form for creating a new resource. |
||
| 93 | * |
||
| 94 | * @return \Illuminate\Http\Response |
||
| 95 | */ |
||
| 96 | public function create() |
||
| 135 | |||
| 136 | /** |
||
| 137 | * Store a newly created resource in storage. |
||
| 138 | * |
||
| 139 | * @param \Illuminate\Http\Request $request |
||
| 140 | * @return \Illuminate\Http\Response |
||
| 141 | */ |
||
| 142 | View Code Duplication | public function store(Request $request) |
|
| 150 | |||
| 151 | /** |
||
| 152 | * Display the specified resource. |
||
| 153 | * |
||
| 154 | * @param \App\JenisSekolah $jenis_sekolah |
||
| 155 | * @return \Illuminate\Http\Response |
||
| 156 | */ |
||
| 157 | View Code Duplication | public function show($id) |
|
| 168 | |||
| 169 | /** |
||
| 170 | * Show the form for editing the specified resource. |
||
| 171 | * |
||
| 172 | * @param \App\JenisSekolah $jenis_sekolah |
||
| 173 | * @return \Illuminate\Http\Response |
||
| 174 | */ |
||
| 175 | View Code Duplication | public function edit($id) |
|
| 186 | |||
| 187 | /** |
||
| 188 | * Update the specified resource in storage. |
||
| 189 | * |
||
| 190 | * @param \Illuminate\Http\Request $request |
||
| 191 | * @param \App\JenisSekolah $jenis_sekolah |
||
| 192 | * @return \Illuminate\Http\Response |
||
| 193 | */ |
||
| 194 | View Code Duplication | public function update(Request $request, $id) |
|
| 202 | |||
| 203 | /** |
||
| 204 | * Remove the specified resource from storage. |
||
| 205 | * |
||
| 206 | * @param \App\JenisSekolah $jenis_sekolah |
||
| 207 | * @return \Illuminate\Http\Response |
||
| 208 | */ |
||
| 209 | View Code Duplication | public function destroy($id) |
|
| 225 | } |
||
| 226 |
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.