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 MartinReviewHandler extends XoopsObjectHandler |
||
24 | { |
||
25 | /** |
||
26 | * @create cart object |
||
27 | * @license http://www.blags.org/ |
||
28 | * @created :2010年07月04日 12时59分 |
||
29 | * @copyright 1997-2010 The Martin Group |
||
30 | * @author Martin <[email protected]> |
||
31 | * */ |
||
32 | public function &create() |
||
38 | |||
39 | /** |
||
40 | * insert review for hotel |
||
41 | * @access public |
||
42 | * @param $Data |
||
43 | * @copyright 1997-2010 The Lap Group |
||
44 | * @author Martin <[email protected]> |
||
45 | * @created time :2010-07-22 16:28:18 |
||
46 | */ |
||
47 | public function SaveReview($Data) |
||
69 | |||
70 | /** |
||
71 | * |
||
72 | * @access public |
||
73 | * @param $hotel_id |
||
74 | * @param $uid |
||
75 | * @return bool |
||
76 | * @copyright 1997-2010 The Lap Group |
||
77 | * @author Martin <[email protected]> |
||
78 | * @created time :2010-07-22 16:43:23 |
||
79 | */ |
||
80 | View Code Duplication | public function CheckReviewExist($hotel_id, $uid) |
|
87 | |||
88 | /** |
||
89 | * |
||
90 | * @access public |
||
91 | * @param $hotel_id |
||
92 | * @copyright 1997-2010 The Lap Group |
||
93 | * @author Martin <[email protected]> |
||
94 | * @created time :2010-07-22 16:49:41 |
||
95 | */ |
||
96 | public function GetReview($hotel_id) |
||
104 | |||
105 | /** |
||
106 | * get hotel review |
||
107 | * @access public |
||
108 | * @param $hotel_id |
||
109 | * @copyright 1997-2010 The Lap Group |
||
110 | * @author Martin <[email protected]> |
||
111 | * @created time :2010-07-22 17:03:32 |
||
112 | */ |
||
113 | public function GetHotelReview($hotel_id) |
||
125 | } |
||
126 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.