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 | View Code Duplication | class TOnActionType |
|
|
|
|||
| 12 | { |
||
| 13 | |||
| 14 | /** |
||
| 15 | * @property string $action |
||
| 16 | */ |
||
| 17 | private $action = null; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @property \MetadataV3\edm\TDocumentationType $documentation |
||
| 21 | */ |
||
| 22 | private $documentation = null; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Gets as action |
||
| 26 | * |
||
| 27 | * @return string |
||
| 28 | */ |
||
| 29 | public function getAction() |
||
| 33 | |||
| 34 | /** |
||
| 35 | * Sets a new action |
||
| 36 | * |
||
| 37 | * @param string $action |
||
| 38 | * @return self |
||
| 39 | */ |
||
| 40 | public function setAction($action) |
||
| 45 | |||
| 46 | /** |
||
| 47 | * Gets as documentation |
||
| 48 | * |
||
| 49 | * @return \MetadataV3\edm\TDocumentationType |
||
| 50 | */ |
||
| 51 | public function getDocumentation() |
||
| 55 | |||
| 56 | /** |
||
| 57 | * Sets a new documentation |
||
| 58 | * |
||
| 59 | * @param \MetadataV3\edm\TDocumentationType $documentation |
||
| 60 | * @return self |
||
| 61 | */ |
||
| 62 | public function setDocumentation(\MetadataV3\edm\TDocumentationType $documentation) |
||
| 67 | } |
||
| 68 |
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.