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 |
||
12 | View Code Duplication | class PrimerTemplate extends BaseTemplate implements TemplateInterface |
|
13 | { |
||
14 | protected $prefix = '<p>'; |
||
15 | protected $postfix = '</p>'; |
||
16 | protected $wrapper = '<div class="flash flash-%s">%s</div>'; |
||
17 | |||
18 | /** |
||
19 | * Override base function to suite Bootstrap 3 alert naming. |
||
20 | * |
||
21 | * @param $messages - message text |
||
22 | * @param $type - message type: success, info, warning, error |
||
23 | * |
||
24 | * @return string |
||
25 | */ |
||
26 | 2 | public function wrapMessages($messages, $type) |
|
32 | } |
||
33 |