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 Pmset extends UPS |
||
|
|
|||
| 27 | { |
||
| 28 | /** |
||
| 29 | * internal storage for all gathered data |
||
| 30 | * |
||
| 31 | * @var array |
||
| 32 | */ |
||
| 33 | private $_output = array(); |
||
| 34 | |||
| 35 | /** |
||
| 36 | * get all information from all configured ups and store output in internal array |
||
| 37 | */ |
||
| 38 | View Code Duplication | public function __construct() |
|
| 46 | |||
| 47 | /** |
||
| 48 | * parse the input and store data in resultset for xml generation |
||
| 49 | * |
||
| 50 | * @return array |
||
| 51 | */ |
||
| 52 | private function _info() |
||
| 78 | |||
| 79 | /** |
||
| 80 | * get the information |
||
| 81 | * |
||
| 82 | * @see PSI_Interface_UPS::build() |
||
| 83 | * |
||
| 84 | * @return Void |
||
| 85 | */ |
||
| 86 | public function build() |
||
| 90 | } |
||
| 91 |
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.