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 K8Temp extends Sensors |
||
|
|
|||
| 27 | { |
||
| 28 | /** |
||
| 29 | * content to parse |
||
| 30 | * |
||
| 31 | * @var array |
||
| 32 | */ |
||
| 33 | private $_lines = array(); |
||
| 34 | |||
| 35 | /** |
||
| 36 | * fill the private array |
||
| 37 | */ |
||
| 38 | View Code Duplication | public function __construct() |
|
| 57 | |||
| 58 | /** |
||
| 59 | * get temperature information |
||
| 60 | * |
||
| 61 | * @return void |
||
| 62 | */ |
||
| 63 | private function _temperature() |
||
| 79 | |||
| 80 | /** |
||
| 81 | * get the information |
||
| 82 | * |
||
| 83 | * @see PSI_Interface_Sensor::build() |
||
| 84 | * |
||
| 85 | * @return Void |
||
| 86 | */ |
||
| 87 | public function build() |
||
| 91 | } |
||
| 92 |
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.