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 BrowseContinentsPage extends BrowseAbstractPage |
||
|
|||
4 | { |
||
5 | |||
6 | /** |
||
7 | * Standard SS static |
||
8 | **/ |
||
9 | public static $icon = "geobrowser/images/treeicons/BrowseContinentsPage"; |
||
10 | |||
11 | |||
12 | /** |
||
13 | * Standard SS static |
||
14 | **/ |
||
15 | public static $allowed_children = array("BrowseCountriesPage"); |
||
16 | |||
17 | /** |
||
18 | * Standard SS static |
||
19 | **/ |
||
20 | public static $default_child = "BrowseCountriesPage"; |
||
21 | |||
22 | /** |
||
23 | * Standard SS static |
||
24 | **/ |
||
25 | public static $default_parent = "BrowseWorldPage"; |
||
26 | |||
27 | /** |
||
28 | * Standard SS Static |
||
29 | **/ |
||
30 | public static $can_be_root = false; |
||
31 | |||
32 | /** |
||
33 | * Standard SS Static |
||
34 | **/ |
||
35 | public static $defaults = array( |
||
36 | "ShowInMenus" => true |
||
37 | ); |
||
38 | |||
39 | /** |
||
40 | * name of the level |
||
41 | **/ |
||
42 | public function GeoLevelName() |
||
46 | |||
47 | /** |
||
48 | * number of the level |
||
49 | **/ |
||
50 | public function GeoLevelNumber() |
||
54 | |||
55 | /** |
||
56 | * Standard SS Method |
||
57 | * setup records |
||
58 | **/ |
||
59 | public function requireDefaultRecords() |
||
81 | |||
82 | /** |
||
83 | * create a continent |
||
84 | * @param array - $contentint, continent data |
||
85 | * @param Object - $parent, a BrowseWorldPage object that will be the parent page of the Continent. |
||
86 | **/ |
||
87 | public function CreateContinent(array $continent, BrowseWorldPage $parent) |
||
117 | } |
||
118 | |||
122 |
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.