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 |
||
| 29 | View Code Duplication | class TipoMedida extends Tipo |
|
| 30 | { |
||
| 31 | /** |
||
| 32 | * @ORM\ManyToOne(targetEntity="CategoriaMedida") |
||
| 33 | * @ORM\JoinColumn(nullable=false) |
||
| 34 | */ |
||
| 35 | protected $categoria; |
||
| 36 | |||
| 37 | /** |
||
| 38 | * Set categoria |
||
| 39 | * |
||
| 40 | * @param CategoriaMedida $categoria |
||
| 41 | * @return self |
||
| 42 | */ |
||
| 43 | public function setCategoria(CategoriaMedida $categoria = null) |
||
| 49 | |||
| 50 | /** |
||
| 51 | * Get categoria |
||
| 52 | * |
||
| 53 | * @return CategoriaMedida |
||
| 54 | */ |
||
| 55 | public function getCategoria() |
||
| 59 | |||
| 60 | public function __toString() |
||
| 64 | } |
||
| 65 |