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 |
||
| 12 | class Cv extends AbstractRepository |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * Gets a pointer to access a CV |
||
| 16 | * |
||
| 17 | * @param array $params |
||
| 18 | */ |
||
| 19 | public function getPaginatorCursor($params) |
||
| 25 | /** |
||
| 26 | * Gets a query builder to search for CVs |
||
| 27 | * |
||
| 28 | * @param array $params |
||
| 29 | * @return unknown |
||
| 30 | */ |
||
| 31 | View Code Duplication | protected function getPaginationQueryBuilder($params) |
|
| 38 | |||
| 39 | /** |
||
| 40 | * Look for an drafted Document of a given user |
||
| 41 | * |
||
| 42 | * @param $user |
||
| 43 | * @return \Cv\Entity\Cv|null |
||
| 44 | */ |
||
| 45 | View Code Duplication | public function findDraft($user) |
|
| 64 | } |
||
| 65 |
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.