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 |
||
4 | class SimpleOffer extends BaseModel |
||
5 | { |
||
6 | /** |
||
7 | * @inheritdoc |
||
8 | */ |
||
9 | public static $tag = 'offer'; |
||
10 | /** |
||
11 | * @inheritdoc |
||
12 | */ |
||
13 | public static $tagProperties = [ |
||
14 | 'id', |
||
15 | 'bid', |
||
16 | 'cbid', |
||
17 | 'available' |
||
18 | ]; |
||
19 | |||
20 | public $id; |
||
21 | public $bid; |
||
22 | public $cbid; |
||
23 | public $available; |
||
24 | |||
25 | public $url; |
||
26 | public $price; |
||
27 | public $oldprice; |
||
28 | public $currencyId; |
||
29 | public $categoryId; |
||
30 | public $market_Category; |
||
31 | public $store; |
||
32 | public $pickup; |
||
33 | public $delivery; |
||
34 | public $local_Delivery_Cost; |
||
35 | public $name; |
||
36 | public $vendor; |
||
37 | public $vendorCode; |
||
38 | public $description; |
||
39 | public $sales_Notes; |
||
40 | public $manufacturer_Warranty; |
||
41 | public $country_Of_Origin; |
||
42 | public $adult; |
||
43 | public $age; |
||
44 | public $barcode; |
||
45 | public $cpa; |
||
46 | public $params = []; |
||
47 | public $pictures = []; |
||
48 | |||
49 | /** |
||
50 | * @inheritdoc |
||
51 | */ |
||
52 | 6 | public function getYmlAttributes() |
|
78 | |||
79 | /** |
||
80 | * @inheritdoc |
||
81 | */ |
||
82 | 6 | public function rules() |
|
155 | |||
156 | /** |
||
157 | * @param array $params |
||
158 | */ |
||
159 | 6 | public function setParams(array $params) |
|
163 | |||
164 | /** |
||
165 | * @param array $pictures |
||
166 | */ |
||
167 | 6 | public function setPictures(array $pictures) |
|
171 | |||
172 | /** |
||
173 | * @inheritdoc |
||
174 | */ |
||
175 | 6 | protected function getYmlBody() |
|
193 | |||
194 | |||
195 | /** |
||
196 | * @param string $attribute |
||
197 | * @param string $value |
||
198 | * @return string |
||
199 | */ |
||
200 | View Code Duplication | protected function getYmlParamTag($attribute, $value) |
|
210 | |||
211 | /** |
||
212 | * @param string $value |
||
213 | * @return string |
||
214 | */ |
||
215 | 6 | View Code Duplication | protected function getYmlPictureTag($value) |
225 | } |
||
226 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.