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 |
||
| 29 | abstract class Middleware implements RequestDecoratorInterface |
||
| 30 | { |
||
| 31 | |||
| 32 | /** |
||
| 33 | * @var RequestDecoratorInterface $request_stack_app |
||
| 34 | */ |
||
| 35 | protected $request_stack_app; |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @var RequestInterface $request |
||
| 39 | */ |
||
| 40 | protected $request; |
||
| 41 | |||
| 42 | /** |
||
| 43 | * @var ResponseInterface $response |
||
| 44 | */ |
||
| 45 | protected $response; |
||
| 46 | |||
| 47 | /** |
||
| 48 | * @var LoaderInterface |
||
| 49 | */ |
||
| 50 | protected $loader; |
||
| 51 | |||
| 52 | |||
| 53 | |||
| 54 | /** |
||
| 55 | * @param RequestDecoratorInterface $request_stack_app |
||
| 56 | * @param LoaderInterface $loader |
||
| 57 | */ |
||
| 58 | public function __construct(RequestDecoratorInterface $request_stack_app, LoaderInterface $loader) |
||
| 63 | |||
| 64 | |||
| 65 | |||
| 66 | /** |
||
| 67 | * process_request_stack |
||
| 68 | * |
||
| 69 | * @param RequestInterface $request |
||
| 70 | * @param ResponseInterface $response |
||
| 71 | * @return ResponseInterface |
||
| 72 | */ |
||
| 73 | View Code Duplication | protected function processRequestStack(RequestInterface $request, ResponseInterface $response) |
|
| 82 | |||
| 83 | |||
| 84 | } |
||
| 85 | // Location: Middleware.php |
||
| 86 |