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 |
||
7 | class FlashObjectDOD extends SiteTreeDecorator |
||
|
|||
8 | { |
||
9 | public function extraStatics() |
||
20 | |||
21 | protected static $classes_with_flash = array(); |
||
22 | public static function set_classes_with_flash($v) |
||
30 | |||
31 | protected static $classes_without_flash = array(); |
||
32 | public static function set_classes_without_flash($v) |
||
40 | |||
41 | public function updateCMSFields(FieldSet &$fields) |
||
62 | |||
63 | public function CreateFlashObject() |
||
73 | |||
74 | /* |
||
75 | legacy function |
||
76 | */ |
||
77 | |||
78 | public function FlashObjectData() |
||
82 | } |
||
83 |
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.