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 |
||
17 | class HorizontalFormRenderer extends AbstractFormRenderer implements FormRendererInterface |
||
|
|||
18 | { |
||
19 | 2 | public function __construct() |
|
27 | |||
28 | /** |
||
29 | * @return DOMElement |
||
30 | */ |
||
31 | 2 | View Code Duplication | public function renderFieldLabel() |
40 | |||
41 | /** |
||
42 | * @return DOMElement |
||
43 | */ |
||
44 | 2 | public function renderFieldBlock() |
|
79 | |||
80 | /** |
||
81 | * Surround an element in a div with a given class |
||
82 | * |
||
83 | * @param DOMElement $element |
||
84 | * @param $class |
||
85 | * @return DOMElement |
||
86 | */ |
||
87 | 2 | private function surroundInDiv(DOMElement $element, $class) |
|
94 | |||
95 | } |