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 CommentsGridFieldBulkAction_Handlers extends CommentsGridFieldBulkAction { |
||
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 | View Code Duplication | public function spam(SS_HTTPRequest $request) { |
|
45 | |||
46 | |||
47 | View Code Duplication | public function approve(SS_HTTPRequest $request) { |
|
64 | } |