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 |
||
| 5 | View Code Duplication | trait CompoundTrait |
|
| 6 | { |
||
| 7 | use OptionAccessorsTrait; |
||
| 8 | |||
| 9 | /** |
||
| 10 | * @param bool $compound |
||
| 11 | * @return bool |
||
| 12 | * @link http://symfony.com/doc/current/reference/forms/types/form.html#compound |
||
| 13 | */ |
||
| 14 | public function setCompound($compound = true) |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @return bool|string |
||
| 21 | * @link http://symfony.com/doc/current/reference/forms/types/form.html#compound |
||
| 22 | */ |
||
| 23 | public function getCompound() |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @return bool |
||
| 30 | * @link http://symfony.com/doc/current/reference/forms/types/form.html#compound |
||
| 31 | */ |
||
| 32 | public function removeCompound() |
||
| 36 | } |
||
| 37 |