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 |
||
| 14 | View Code Duplication | class DoctrineORMRepository extends ORMRepository implements WebPageRepository |
|
| 15 | { |
||
| 16 | /** |
||
| 17 | * @param mixed $id |
||
| 18 | * @return mixed |
||
| 19 | * @throws \Doctrine\ORM\NoResultException |
||
| 20 | * @throws \Doctrine\ORM\NonUniqueResultException |
||
| 21 | */ |
||
| 22 | public function find(WebPageId $id) |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @param $slug |
||
| 38 | * @return mixed|null |
||
| 39 | */ |
||
| 40 | public function findBySlug($slug) |
||
| 53 | |||
| 54 | /** |
||
| 55 | * @return mixed |
||
| 56 | */ |
||
| 57 | public function findAll() |
||
| 61 | |||
| 62 | /** |
||
| 63 | * @param WebPage $webpage |
||
| 64 | */ |
||
| 65 | public function add(WebPage $webpage) |
||
| 70 | |||
| 71 | /** |
||
| 72 | * @param WebPage $webpage |
||
| 73 | */ |
||
| 74 | public function remove(WebPage $webpage) |
||
| 80 | |||
| 81 | public function update(WebPage $webpage) |
||
| 85 | } |
||
| 86 |