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 BootstrapTemplate extends BaseTemplate implements TemplateInterface |
|
| 13 | { |
||
| 14 | protected $prefix = ''; |
||
| 15 | protected $postfix = '<br />'; |
||
| 16 | protected $wrapper = '<div class="alert alert-%s" role="alert">%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 | 48 | public function wrapMessages($messages, $type) |
|
| 32 | } |
||
| 33 |