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 |
||
28 | abstract class Middleware implements EEI_Request_Decorator |
||
29 | { |
||
30 | |||
31 | /** |
||
32 | * @type EEI_Request_Decorator $request_stack |
||
33 | */ |
||
34 | protected $request_stack; |
||
35 | |||
36 | /** |
||
37 | * @type EE_Request $request |
||
38 | */ |
||
39 | protected $request; |
||
40 | |||
41 | /** |
||
42 | * @type EE_Response $response |
||
43 | */ |
||
44 | protected $response; |
||
45 | |||
46 | |||
47 | |||
48 | /** |
||
49 | * @param \EEI_Request_Decorator $request_stack |
||
50 | */ |
||
51 | public function __construct(EEI_Request_Decorator $request_stack) |
||
55 | |||
56 | |||
57 | |||
58 | /** |
||
59 | * process_request_stack |
||
60 | * |
||
61 | * @param EE_Request $request |
||
62 | * @param EE_Response $response |
||
63 | * @return EE_Response |
||
64 | */ |
||
65 | View Code Duplication | protected function process_request_stack(EE_Request $request, EE_Response $response) |
|
74 | |||
75 | |||
76 | } |
||
77 | // Location: Middleware.php |
||
78 |