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 |
||
11 | class Pipeline extends BaseEntity |
||
12 | { |
||
13 | /** |
||
14 | * @var string Имя воронки |
||
15 | */ |
||
16 | public $name; |
||
17 | |||
18 | /** |
||
19 | * @var integer Порядковый номер воронки при отображении |
||
20 | */ |
||
21 | public $sort; |
||
22 | |||
23 | /** |
||
24 | * @var string Является ли воронка "главной" (необходимо передать значение "on", если является) |
||
25 | */ |
||
26 | public $is_main; |
||
27 | |||
28 | /** |
||
29 | * @var array |
||
30 | */ |
||
31 | protected $fieldList = ['id', 'name', 'sort', 'is_main']; |
||
32 | |||
33 | use StatusAddable; |
||
34 | |||
35 | /** |
||
36 | * @return array |
||
37 | */ |
||
38 | 6 | View Code Duplication | public function get() |
53 | } |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.