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 |
||
| 26 | class Webpage extends Output implements PSI_Interface_Output |
||
|
|
|||
| 27 | { |
||
| 28 | /** |
||
| 29 | * configured indexname |
||
| 30 | * |
||
| 31 | * @var String |
||
| 32 | */ |
||
| 33 | private $_indexname; |
||
| 34 | |||
| 35 | /** |
||
| 36 | * configured language |
||
| 37 | * |
||
| 38 | * @var String |
||
| 39 | */ |
||
| 40 | private $_language; |
||
| 41 | |||
| 42 | /** |
||
| 43 | * configured template |
||
| 44 | * |
||
| 45 | * @var String |
||
| 46 | */ |
||
| 47 | private $_template; |
||
| 48 | |||
| 49 | /** |
||
| 50 | * all available templates |
||
| 51 | * |
||
| 52 | * @var Array |
||
| 53 | */ |
||
| 54 | private $_templates = array(); |
||
| 55 | |||
| 56 | /** |
||
| 57 | * configured bootstrap template |
||
| 58 | * |
||
| 59 | * @var String |
||
| 60 | */ |
||
| 61 | private $_bootstrap_template; |
||
| 62 | |||
| 63 | /** |
||
| 64 | * all available bootstrap templates |
||
| 65 | * |
||
| 66 | * @var Array |
||
| 67 | */ |
||
| 68 | private $_bootstrap_templates = array(); |
||
| 69 | |||
| 70 | /** |
||
| 71 | * all available languages |
||
| 72 | * |
||
| 73 | * @var Array |
||
| 74 | */ |
||
| 75 | private $_languages = array(); |
||
| 76 | |||
| 77 | /** |
||
| 78 | * configured show picklist language |
||
| 79 | * |
||
| 80 | * @var boolean |
||
| 81 | */ |
||
| 82 | private $_pick_language; |
||
| 83 | |||
| 84 | /** |
||
| 85 | * configured show picklist template |
||
| 86 | * |
||
| 87 | * @var boolean |
||
| 88 | */ |
||
| 89 | private $_pick_template; |
||
| 90 | |||
| 91 | /** |
||
| 92 | * check for all extensions that are needed, initialize needed vars and read phpsysinfo.ini |
||
| 93 | */ |
||
| 94 | public function __construct($indexname="dynamic") |
||
| 101 | |||
| 102 | /** |
||
| 103 | * checking phpsysinfo.ini setting for template, if not supportet set phpsysinfo.css as default |
||
| 104 | * checking phpsysinfo.ini setting for language, if not supported set en as default |
||
| 105 | * |
||
| 106 | * @return void |
||
| 107 | */ |
||
| 108 | private function _checkTemplateLanguage() |
||
| 123 | |||
| 124 | /** |
||
| 125 | * get all available tamplates and store them in internal array |
||
| 126 | * |
||
| 127 | * @return void |
||
| 128 | */ |
||
| 129 | private function _getTemplateList() |
||
| 145 | |||
| 146 | /** |
||
| 147 | * get all available translations and store them in internal array |
||
| 148 | * |
||
| 149 | * @return void |
||
| 150 | */ |
||
| 151 | private function _getLanguageList() |
||
| 163 | |||
| 164 | /** |
||
| 165 | * render the page |
||
| 166 | * |
||
| 167 | * @return void |
||
| 168 | */ |
||
| 169 | public function run() |
||
| 190 | } |
||
| 191 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.