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 |
||
5 | class BrowseWorldPage extends BrowseAbstractPage |
||
|
|||
6 | { |
||
7 | |||
8 | /** |
||
9 | * Standard SS Static |
||
10 | **/ |
||
11 | public static $icon = "geobrowser/images/treeicons/BrowseWorldPage"; |
||
12 | |||
13 | /** |
||
14 | * Standard SS static |
||
15 | **/ |
||
16 | public static $allowed_children = array("BrowseContinentsPage"); |
||
17 | |||
18 | /** |
||
19 | * Standard SS Static |
||
20 | **/ |
||
21 | public static $default_child = "BrowseContinentsPage"; |
||
22 | |||
23 | /** |
||
24 | * Standard SS Static |
||
25 | **/ |
||
26 | public static $db = array( |
||
27 | "LevelOfDetail" => "Int", |
||
28 | ); |
||
29 | |||
30 | /** |
||
31 | * Standard SS Static |
||
32 | **/ |
||
33 | public static $defaults = array( |
||
34 | "CreateChildren" => true, |
||
35 | "LevelOfDetail" => 2, |
||
36 | "ShowInMenus" => true |
||
37 | ); |
||
38 | |||
39 | /** |
||
40 | * @var Array |
||
41 | * Sets the level of detail in terms of the pages that are automatically created. |
||
42 | **/ |
||
43 | protected static $LevelOfDetailArray = array( |
||
44 | "0" => "Continents", |
||
45 | "1" => "Countries", |
||
46 | "2" => "Regions", |
||
47 | "3" => "Cities", |
||
48 | "4" => "Suburbs" |
||
49 | ); |
||
50 | |||
51 | |||
52 | public function getCMSFields() |
||
58 | |||
59 | /** |
||
60 | * Standard SS function |
||
61 | * Creating level of detail |
||
62 | * Note that the _GET variable "geobuild" needs to be turned on. |
||
63 | **/ |
||
64 | public function requireDefaultRecords() |
||
86 | } |
||
87 | |||
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.