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 namespace WITR\Http\Controllers\Admin; |
||
12 | class EventController extends Controller { |
||
13 | |||
14 | public function __construct() |
||
19 | |||
20 | /** |
||
21 | * Display a listing of the Events. |
||
22 | * |
||
23 | * @return Response |
||
24 | */ |
||
25 | public function index() |
||
30 | |||
31 | /** |
||
32 | * Display a listing of the resource. |
||
33 | * |
||
34 | * @return Response |
||
35 | */ |
||
36 | public function new_event() |
||
40 | |||
41 | /** |
||
42 | * Save the new Event |
||
43 | * |
||
44 | * @return Response |
||
45 | */ |
||
46 | public function create(Requests\CreateRequest $request) |
||
58 | |||
59 | public function edit($id) |
||
65 | |||
66 | public function update(Requests\UpdateRequest $request, $id) |
||
84 | |||
85 | View Code Duplication | public function delete($id) |
|
93 | |||
94 | } |
||
95 |
Since your code implements the magic setter
_set
, this function will be called for any write access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.Since the property has write access only, you can use the @property-write annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.