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 |
||
6 | class TrainingMemberDecorator extends DataExtension |
||
|
|||
7 | { |
||
8 | private static $belongs_many_many = array( |
||
9 | 'Training' => 'TrainingPage' |
||
10 | ); |
||
11 | private static $db = array( |
||
12 | 'Organisation' => 'Varchar', |
||
13 | 'Phone' => 'Varchar' |
||
14 | ); |
||
15 | |||
16 | |||
17 | |||
18 | public function getTrainingFields() |
||
29 | |||
30 | public function getTrainingRequiredFields() |
||
41 | |||
42 | public static function createOrMerge($data) |
||
70 | } |
||
71 |
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.