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 |
||
| 15 | View Code Duplication | class DoctrineMongoDBRepository extends MongoDBRepository implements WebPageRepository |
|
| 16 | { |
||
| 17 | /** |
||
| 18 | * @param mixed $id |
||
| 19 | * @return mixed |
||
| 20 | * @throws \Doctrine\ORM\NoResultException |
||
| 21 | * @throws \Doctrine\ORM\NonUniqueResultException |
||
| 22 | */ |
||
| 23 | public function find(WebPageId $id) |
||
| 35 | |||
| 36 | public function findBySlug($slug) |
||
| 48 | |||
| 49 | /** |
||
| 50 | * @return mixed |
||
| 51 | */ |
||
| 52 | public function findAll() |
||
| 56 | |||
| 57 | /** |
||
| 58 | * @param WebPage $webpage |
||
| 59 | */ |
||
| 60 | public function add(WebPage $webpage) |
||
| 65 | |||
| 66 | /** |
||
| 67 | * @param WebPage $webpage |
||
| 68 | */ |
||
| 69 | public function remove(WebPage $webpage) |
||
| 75 | |||
| 76 | public function update(WebPage $webpage) |
||
| 80 | } |
||
| 81 |