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 LDAPDebugController extends ContentController |
||
|
|||
8 | { |
||
9 | |||
10 | /** |
||
11 | * @var array |
||
12 | */ |
||
13 | private static $allowed_actions = [ |
||
14 | 'index', |
||
15 | ]; |
||
16 | |||
17 | /** |
||
18 | * @var array |
||
19 | */ |
||
20 | private static $dependencies = [ |
||
21 | 'ldapService' => '%$LDAPService' |
||
22 | ]; |
||
23 | |||
24 | /** |
||
25 | * @var LDAPService |
||
26 | */ |
||
27 | public $ldapService; |
||
28 | |||
29 | public function init() |
||
37 | |||
38 | /** |
||
39 | * @param SS_HTTPRequest $request |
||
40 | * |
||
41 | * @return string |
||
42 | */ |
||
43 | public function index(\SS_HTTPRequest $request) { |
||
46 | |||
47 | public function Options() |
||
62 | |||
63 | View Code Duplication | public function UsersSearchLocations() |
|
79 | |||
80 | View Code Duplication | public function GroupsSearchLocations() |
|
96 | |||
97 | public function DefaultGroup() |
||
114 | |||
115 | public function MappedGroups() |
||
119 | |||
120 | View Code Duplication | public function Nodes() |
|
131 | |||
132 | View Code Duplication | public function Groups() |
|
143 | |||
144 | public function Users() |
||
148 | } |
||
149 |
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.