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 |
||
| 7 | class SimpleOffer extends BaseModel |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * @inheritdoc |
||
| 11 | */ |
||
| 12 | public static $tag = 'offer'; |
||
| 13 | /** |
||
| 14 | * @inheritdoc |
||
| 15 | */ |
||
| 16 | public static $tagProperties = [ |
||
| 17 | 'id', |
||
| 18 | 'bid', |
||
| 19 | 'cbid', |
||
| 20 | 'available' |
||
| 21 | ]; |
||
| 22 | |||
| 23 | public $id; |
||
| 24 | public $bid; |
||
| 25 | public $cbid; |
||
| 26 | public $available; |
||
| 27 | |||
| 28 | public $url; |
||
| 29 | public $price; |
||
| 30 | public $oldprice; |
||
| 31 | public $currencyId; |
||
| 32 | public $categoryId; |
||
| 33 | public $market_Category; |
||
| 34 | public $store; |
||
| 35 | public $pickup; |
||
| 36 | public $delivery; |
||
| 37 | public $local_Delivery_Cost; |
||
| 38 | public $name; |
||
| 39 | public $vendor; |
||
| 40 | public $vendorCode; |
||
| 41 | public $description; |
||
| 42 | public $sales_notes; |
||
| 43 | public $manufacturer_Warranty; |
||
| 44 | public $country_Of_Origin; |
||
| 45 | public $adult; |
||
| 46 | public $age; |
||
| 47 | public $barcode; |
||
| 48 | public $cpa; |
||
| 49 | public $params = []; |
||
| 50 | public $pictures = []; |
||
| 51 | /** |
||
| 52 | 6 | * Опции доставки |
|
| 53 | * |
||
| 54 | * @var array |
||
| 55 | 6 | */ |
|
| 56 | 4 | public $deliveryOptions = []; |
|
| 57 | 4 | ||
| 58 | 4 | /** |
|
| 59 | 4 | * @inheritdoc |
|
| 60 | 4 | */ |
|
| 61 | 4 | public function getYmlAttributes() |
|
| 87 | 4 | ||
| 88 | 6 | /** |
|
| 89 | * @inheritdoc |
||
| 90 | 4 | */ |
|
| 91 | 4 | public function rules() |
|
| 171 | |||
| 172 | 6 | /** |
|
| 173 | 6 | * @param array $params |
|
| 174 | */ |
||
| 175 | public function setParams(array $params) |
||
| 179 | |||
| 180 | 6 | /** |
|
| 181 | * @param array $pictures |
||
| 182 | 6 | */ |
|
| 183 | 6 | public function setPictures(array $pictures) |
|
| 187 | |||
| 188 | 4 | /** |
|
| 189 | * @param array $options |
||
| 190 | 6 | * |
|
| 191 | 6 | * @throws Exception |
|
| 192 | 4 | */ |
|
| 193 | public function setDeliveryOptions(array $options) |
||
| 200 | |||
| 201 | /** |
||
| 202 | * @inheritdoc |
||
| 203 | */ |
||
| 204 | protected function getYmlBody() |
||
| 224 | 6 | ||
| 225 | /** |
||
| 226 | 6 | * Добавляет теги ддля опций доставки |
|
| 227 | * |
||
| 228 | * @param $string |
||
| 229 | * |
||
| 230 | * @throws Exception |
||
| 231 | */ |
||
| 232 | protected function appendDeliveryOptions(&$string) { |
||
| 241 | |||
| 242 | |||
| 243 | /** |
||
| 244 | * @param string $attribute |
||
| 245 | * @param string $value |
||
| 246 | * @return string |
||
| 247 | */ |
||
| 248 | View Code Duplication | protected function getYmlParamTag($attribute, $value) |
|
| 258 | |||
| 259 | /** |
||
| 260 | * @param string $value |
||
| 261 | * @return string |
||
| 262 | */ |
||
| 263 | View Code Duplication | protected function getYmlPictureTag($value) |
|
| 273 | } |
||
| 274 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.