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 | class Handler extends GridFieldBulkActionHandler |
||
16 | { |
||
17 | private static $allowed_actions = array( |
||
18 | 'spam', |
||
19 | 'approve', |
||
20 | ); |
||
21 | |||
22 | private static $url_handlers = array( |
||
23 | 'spam' => 'spam', |
||
24 | 'approve' => 'approve', |
||
25 | ); |
||
26 | |||
27 | /** |
||
28 | * @param HTTPRequest $request |
||
29 | * @return HTTPResponse |
||
30 | */ |
||
31 | View Code Duplication | public function spam(HTTPRequest $request) |
|
49 | |||
50 | /** |
||
51 | * @param HTTPRequest $request |
||
52 | * @return HTTPResponse |
||
53 | */ |
||
54 | View Code Duplication | public function approve(HTTPRequest $request) |
|
72 | } |
||
73 |
This check marks private properties in classes that are never used. Those properties can be removed.