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 |
||
| 21 | View Code Duplication | class CStudentPublicationRelDocument |
|
|
|
|||
| 22 | { |
||
| 23 | /** |
||
| 24 | * @var integer |
||
| 25 | * |
||
| 26 | * @ORM\Column(name="iid", type="integer") |
||
| 27 | * @ORM\Id |
||
| 28 | * @ORM\GeneratedValue |
||
| 29 | */ |
||
| 30 | private $iid; |
||
| 31 | |||
| 32 | /** |
||
| 33 | * @var integer |
||
| 34 | * |
||
| 35 | * @ORM\Column(name="c_id", type="integer") |
||
| 36 | */ |
||
| 37 | private $cId; |
||
| 38 | |||
| 39 | /** |
||
| 40 | * @var integer |
||
| 41 | * |
||
| 42 | * @ORM\Column(name="id", type="integer", nullable=true) |
||
| 43 | */ |
||
| 44 | private $id; |
||
| 45 | |||
| 46 | /** |
||
| 47 | * @var integer |
||
| 48 | * |
||
| 49 | * @ORM\Column(name="work_id", type="integer", nullable=false) |
||
| 50 | */ |
||
| 51 | private $workId; |
||
| 52 | |||
| 53 | /** |
||
| 54 | * @var integer |
||
| 55 | * |
||
| 56 | * @ORM\Column(name="document_id", type="integer", nullable=false) |
||
| 57 | */ |
||
| 58 | private $documentId; |
||
| 59 | |||
| 60 | /** |
||
| 61 | * Set workId |
||
| 62 | * |
||
| 63 | * @param integer $workId |
||
| 64 | * @return CStudentPublicationRelDocument |
||
| 65 | */ |
||
| 66 | public function setWorkId($workId) |
||
| 72 | |||
| 73 | /** |
||
| 74 | * Get workId |
||
| 75 | * |
||
| 76 | * @return integer |
||
| 77 | */ |
||
| 78 | public function getWorkId() |
||
| 82 | |||
| 83 | /** |
||
| 84 | * Set documentId |
||
| 85 | * |
||
| 86 | * @param integer $documentId |
||
| 87 | * @return CStudentPublicationRelDocument |
||
| 88 | */ |
||
| 89 | public function setDocumentId($documentId) |
||
| 95 | |||
| 96 | /** |
||
| 97 | * Get documentId |
||
| 98 | * |
||
| 99 | * @return integer |
||
| 100 | */ |
||
| 101 | public function getDocumentId() |
||
| 105 | |||
| 106 | /** |
||
| 107 | * Set cId |
||
| 108 | * |
||
| 109 | * @param integer $cId |
||
| 110 | * @return CStudentPublicationRelDocument |
||
| 111 | */ |
||
| 112 | public function setCId($cId) |
||
| 118 | |||
| 119 | /** |
||
| 120 | * Get cId |
||
| 121 | * |
||
| 122 | * @return integer |
||
| 123 | */ |
||
| 124 | public function getCId() |
||
| 128 | |||
| 129 | /** |
||
| 130 | * Get id |
||
| 131 | * |
||
| 132 | * @return integer |
||
| 133 | */ |
||
| 134 | public function getId() |
||
| 138 | } |
||
| 139 |
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.