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 |
||
| 41 | View Code Duplication | class GSSharesRequestBuilder extends CoreRequestBuilder { |
|
|
|
|||
| 42 | |||
| 43 | |||
| 44 | /** |
||
| 45 | * Base of the Sql Insert request for Shares |
||
| 46 | * |
||
| 47 | * @return IQueryBuilder |
||
| 48 | */ |
||
| 49 | protected function getGSSharesInsertSql() { |
||
| 55 | |||
| 56 | |||
| 57 | /** |
||
| 58 | * Base of the Sql Update request for Groups |
||
| 59 | * |
||
| 60 | * @return IQueryBuilder |
||
| 61 | */ |
||
| 62 | protected function getGSSharesUpdateSql() { |
||
| 68 | |||
| 69 | |||
| 70 | /** |
||
| 71 | * @return IQueryBuilder |
||
| 72 | */ |
||
| 73 | protected function getGSSharesSelectSql() { |
||
| 87 | |||
| 88 | |||
| 89 | /** |
||
| 90 | * Base of the Sql Delete request |
||
| 91 | * |
||
| 92 | * @return IQueryBuilder |
||
| 93 | */ |
||
| 94 | protected function getGSSharesDeleteSql() { |
||
| 100 | |||
| 101 | |||
| 102 | /** |
||
| 103 | * @param array $data |
||
| 104 | * |
||
| 105 | * @return GSShare |
||
| 106 | */ |
||
| 107 | protected function parseGSSharesSelectSql($data): GSShare { |
||
| 113 | |||
| 114 | } |
||
| 115 |
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.