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 |
||
24 | class Text extends Element |
||
25 | { |
||
26 | /** |
||
27 | * __construct |
||
28 | * |
||
29 | * @param string|array $caption Caption or array of all attributes |
||
30 | * @param string $name name attribute |
||
31 | * @param integer $size Size |
||
32 | * @param integer $maxlength Maximum length of text |
||
33 | * @param string $value Initial text |
||
34 | * @param string $placeholder placeholder for this element. |
||
35 | */ |
||
36 | 6 | View Code Duplication | public function __construct($caption, $name = null, $size = 10, $maxlength = 64, $value = '', $placeholder = '') |
52 | |||
53 | /** |
||
54 | * Get size |
||
55 | * |
||
56 | * @return int |
||
57 | */ |
||
58 | 1 | public function getSize() |
|
62 | |||
63 | /** |
||
64 | * Get maximum text length |
||
65 | * |
||
66 | * @return int |
||
67 | */ |
||
68 | 1 | public function getMaxlength() |
|
72 | |||
73 | /** |
||
74 | * Get placeholder for this element |
||
75 | * |
||
76 | * @return string |
||
77 | */ |
||
78 | 1 | public function getPlaceholder() |
|
82 | |||
83 | /** |
||
84 | * Prepare HTML for output |
||
85 | * |
||
86 | * @return string HTML |
||
87 | */ |
||
88 | 4 | public function render() |
|
99 | } |
||
100 |