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 |
||
15 | View Code Duplication | class WordPoints_BP_Entity_Group extends WordPoints_BP_Entity { |
|
|
|||
16 | |||
17 | /** |
||
18 | * @since 1.0.0 |
||
19 | */ |
||
20 | protected $bp_component = 'groups'; |
||
21 | |||
22 | /** |
||
23 | * @since 1.0.0 |
||
24 | */ |
||
25 | protected $id_field = 'id'; |
||
26 | |||
27 | /** |
||
28 | * @since 1.2.1 |
||
29 | */ |
||
30 | protected $id_is_int = true; |
||
31 | |||
32 | /** |
||
33 | * @since 1.0.0 |
||
34 | */ |
||
35 | protected $human_id_field = 'name'; |
||
36 | |||
37 | /** |
||
38 | * @since 1.0.0 |
||
39 | */ |
||
40 | protected function get_entity( $id ) { |
||
50 | |||
51 | /** |
||
52 | * @since 1.0.0 |
||
53 | */ |
||
54 | public function get_title() { |
||
57 | } |
||
58 | |||
60 |
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.