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 |
||
38 | View Code Duplication | class ManyToMany implements MappingConfig |
|
|
|||
39 | { |
||
40 | /** |
||
41 | * @var string |
||
42 | */ |
||
43 | private $targetEntity; |
||
44 | |||
45 | /** |
||
46 | * @var string |
||
47 | */ |
||
48 | private $inversedBy; |
||
49 | |||
50 | /** |
||
51 | * @var string |
||
52 | */ |
||
53 | private $mappedBy; |
||
54 | |||
55 | /** |
||
56 | * @var JoinTable |
||
57 | */ |
||
58 | private $joinTable; |
||
59 | |||
60 | 1 | public function getTargetEntity() |
|
64 | |||
65 | 1 | public function getInversedBy() |
|
69 | |||
70 | 1 | public function getMappedBy() |
|
74 | |||
75 | 1 | public function getJoinTable() |
|
79 | |||
80 | 1 | public function setTargetEntity($targetEntity) |
|
84 | |||
85 | 1 | public function setInversedBy($inversedBy) |
|
89 | |||
90 | 1 | public function setMappedBy($mappedBy) |
|
94 | |||
95 | 1 | public function setJoinTable(JoinTable $joinTable) |
|
99 | } |
||
100 |
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.