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 |
||
| 43 | View Code Duplication | class GSEventsRequestBuilder extends CoreRequestBuilder { |
|
|
|
|||
| 44 | |||
| 45 | |||
| 46 | /** |
||
| 47 | * Base of the Sql Insert request for Shares |
||
| 48 | * |
||
| 49 | * @return IQueryBuilder |
||
| 50 | */ |
||
| 51 | protected function getGSEventsInsertSql() { |
||
| 57 | |||
| 58 | |||
| 59 | /** |
||
| 60 | * Base of the Sql Update request for Groups |
||
| 61 | * |
||
| 62 | * @return IQueryBuilder |
||
| 63 | */ |
||
| 64 | protected function getGSEventsUpdateSql() { |
||
| 70 | |||
| 71 | |||
| 72 | /** |
||
| 73 | * @return IQueryBuilder |
||
| 74 | */ |
||
| 75 | protected function getGSEventsSelectSql() { |
||
| 86 | |||
| 87 | |||
| 88 | /** |
||
| 89 | * Base of the Sql Delete request |
||
| 90 | * |
||
| 91 | * @return IQueryBuilder |
||
| 92 | */ |
||
| 93 | protected function getGSEventsDeleteSql() { |
||
| 99 | |||
| 100 | |||
| 101 | /** |
||
| 102 | * @param array $data |
||
| 103 | * |
||
| 104 | * @return GSWrapper |
||
| 105 | * @throws JsonException |
||
| 106 | * @throws ModelException |
||
| 107 | */ |
||
| 108 | protected function parseGSEventsSelectSql($data): GSWrapper { |
||
| 114 | |||
| 115 | } |
||
| 116 |
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.