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 MBMon extends Sensors |
||
|
|
|||
| 27 | { |
||
| 28 | /** |
||
| 29 | * content to parse |
||
| 30 | * |
||
| 31 | * @var array |
||
| 32 | */ |
||
| 33 | private $_lines = array(); |
||
| 34 | |||
| 35 | /** |
||
| 36 | * fill the private content var through tcp, command or data access |
||
| 37 | */ |
||
| 38 | public function __construct() |
||
| 68 | |||
| 69 | /** |
||
| 70 | * get temperature information |
||
| 71 | * |
||
| 72 | * @return void |
||
| 73 | */ |
||
| 74 | View Code Duplication | private function _temperature() |
|
| 90 | |||
| 91 | /** |
||
| 92 | * get fan information |
||
| 93 | * |
||
| 94 | * @return void |
||
| 95 | */ |
||
| 96 | View Code Duplication | private function _fans() |
|
| 110 | |||
| 111 | /** |
||
| 112 | * get voltage information |
||
| 113 | * |
||
| 114 | * @return void |
||
| 115 | */ |
||
| 116 | View Code Duplication | private function _voltage() |
|
| 129 | |||
| 130 | /** |
||
| 131 | * get the information |
||
| 132 | * |
||
| 133 | * @see PSI_Interface_Sensor::build() |
||
| 134 | * |
||
| 135 | * @return void |
||
| 136 | */ |
||
| 137 | public function build() |
||
| 143 | } |
||
| 144 |
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.