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 BrowseRegionsPage extends BrowseAbstractPage |
||
|
|
|||
| 4 | { |
||
| 5 | |||
| 6 | /** |
||
| 7 | * Standard SS Static |
||
| 8 | **/ |
||
| 9 | public static $icon = "geobrowser/images/treeicons/BrowseRegionsPage"; |
||
| 10 | |||
| 11 | /** |
||
| 12 | * Standard SS Static |
||
| 13 | **/ |
||
| 14 | public static $allowed_children = array("BrowseCitiesPage"); |
||
| 15 | |||
| 16 | /** |
||
| 17 | * Standard SS Static |
||
| 18 | **/ |
||
| 19 | public static $default_child = "BrowseCitiesPage"; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * Standard SS Static |
||
| 23 | **/ |
||
| 24 | public static $default_parent = "BrowseCountriesPage"; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * Standard SS Static |
||
| 28 | **/ |
||
| 29 | public static $can_be_root = false; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * Standard SS Static |
||
| 33 | **/ |
||
| 34 | public static $db = array( |
||
| 35 | "Code" => "Varchar(8)", |
||
| 36 | ); |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Standard SS Static |
||
| 40 | **/ |
||
| 41 | public static $defaults = array( |
||
| 42 | "ShowInMenus" => false |
||
| 43 | ); |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Standard SS Static |
||
| 47 | **/ |
||
| 48 | public function getCMSFields() |
||
| 53 | |||
| 54 | |||
| 55 | /** |
||
| 56 | * Name of the level |
||
| 57 | **/ |
||
| 58 | public function GeoLevelName() |
||
| 62 | |||
| 63 | /** |
||
| 64 | * Number of the level |
||
| 65 | **/ |
||
| 66 | public function GeoLevelNumber() |
||
| 70 | |||
| 71 | |||
| 72 | /** |
||
| 73 | * Setup pages... |
||
| 74 | **/ |
||
| 75 | public function requireDefaultRecords() |
||
| 98 | |||
| 99 | /** |
||
| 100 | * Creates a region... called from BrowseCountriesPage |
||
| 101 | * |
||
| 102 | *@param Array $region - array of region details |
||
| 103 | *@param Object $parent - a BrowseCountriesPage object |
||
| 104 | * |
||
| 105 | **/ |
||
| 106 | public function CreateRegion(array $region, BrowseCountriesPage $parent) |
||
| 141 | } |
||
| 142 | |||
| 146 |
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.