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 |
||
8 | class SimpleOffer extends BaseModel |
||
9 | { |
||
10 | /** |
||
11 | * @inheritdoc |
||
12 | */ |
||
13 | public static $tag = 'offer'; |
||
14 | /** |
||
15 | * @inheritdoc |
||
16 | */ |
||
17 | public static $tagProperties = [ |
||
18 | 'id', |
||
19 | 'bid', |
||
20 | 'cbid', |
||
21 | 'available' |
||
22 | ]; |
||
23 | |||
24 | public $id; |
||
25 | public $bid; |
||
26 | public $cbid; |
||
27 | public $available; |
||
28 | |||
29 | public $url; |
||
30 | public $price; |
||
31 | public $oldprice; |
||
32 | public $currencyId; |
||
33 | public $categoryId; |
||
34 | public $market_Category; |
||
35 | public $store; |
||
36 | public $pickup; |
||
37 | public $delivery; |
||
38 | public $local_Delivery_Cost; |
||
39 | public $name; |
||
40 | public $vendor; |
||
41 | public $vendorCode; |
||
42 | public $description; |
||
43 | public $sales_notes; |
||
44 | public $manufacturer_Warranty; |
||
45 | public $country_Of_Origin; |
||
46 | public $adult; |
||
47 | public $age; |
||
48 | public $barcode; |
||
49 | public $cpa; |
||
50 | public $params = []; |
||
51 | public $pictures = []; |
||
52 | /** |
||
53 | * Опции доставки |
||
54 | * |
||
55 | * @var array |
||
56 | */ |
||
57 | public $deliveryOptions = []; |
||
58 | |||
59 | /** |
||
60 | * @inheritdoc |
||
61 | */ |
||
62 | 4 | public function getYmlAttributes() |
|
88 | |||
89 | /** |
||
90 | * @inheritdoc |
||
91 | */ |
||
92 | 4 | public function rules() |
|
175 | |||
176 | /** |
||
177 | * @param array $params |
||
178 | */ |
||
179 | 5 | public function setParams(array $params) |
|
183 | |||
184 | /** |
||
185 | * @param array $pictures |
||
186 | */ |
||
187 | 5 | public function setPictures(array $pictures) |
|
191 | |||
192 | /** |
||
193 | * @param array $options |
||
194 | * |
||
195 | * @throws Exception |
||
196 | */ |
||
197 | 5 | public function setDeliveryOptions(array $options) |
|
204 | |||
205 | /** |
||
206 | * @inheritdoc |
||
207 | */ |
||
208 | 4 | protected function getYmlBody() |
|
228 | |||
229 | /** |
||
230 | * Добавляет теги ддля опций доставки |
||
231 | * |
||
232 | * @param $string |
||
233 | * |
||
234 | * @throws Exception |
||
235 | */ |
||
236 | 4 | protected function appendDeliveryOptions(&$string) { |
|
249 | |||
250 | |||
251 | /** |
||
252 | * @param string $attribute |
||
253 | * @param string $value |
||
254 | * @return string |
||
255 | */ |
||
256 | View Code Duplication | protected function getYmlParamTag($attribute, $value) |
|
266 | |||
267 | /** |
||
268 | * @param string $value |
||
269 | * @return string |
||
270 | */ |
||
271 | 4 | View Code Duplication | protected function getYmlPictureTag($value) |
281 | } |
||
282 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.