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 |
||
| 3 | class EcommerceDashboardPanel_LatestOrders extends EcommerceDashboardPanel |
||
|
|
|||
| 4 | { |
||
| 5 | private static $icon = "ecommerce_dashboard/images/icons/EcommerceDashboardPanel_LatestOrders.png"; |
||
| 6 | |||
| 7 | private static $db = array( |
||
| 8 | 'NumberOfOrdersToShow' => 'Int' |
||
| 9 | ); |
||
| 10 | |||
| 11 | private static $has_one = array( |
||
| 12 | 'EcommerceCurrency' => 'EcommerceCurrency' |
||
| 13 | ); |
||
| 14 | |||
| 15 | private static $defaults = array( |
||
| 16 | 'NumberOfOrdersToShow' => 7 |
||
| 17 | ); |
||
| 18 | |||
| 19 | public function getLabelPrefix() |
||
| 29 | |||
| 30 | public function getConfiguration() |
||
| 52 | |||
| 53 | public function Content() |
||
| 85 | |||
| 86 | public function onBeforeWrite() |
||
| 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.