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 |
||
21 | View Code Duplication | class TerminateEvent extends Event |
|
22 | { |
||
23 | /** @var CommandInterface */ |
||
24 | private $command; |
||
25 | |||
26 | /** @var ResponseInterface */ |
||
27 | private $response; |
||
28 | |||
29 | /** |
||
30 | * |
||
31 | * @param CommandInterface $command |
||
32 | * @param ResponseInterface $response |
||
33 | */ |
||
34 | public function __construct(CommandInterface $command, ResponseInterface $response) |
||
39 | |||
40 | /** |
||
41 | * |
||
42 | * @param CommandInterface |
||
43 | */ |
||
44 | public function getCommand() |
||
48 | |||
49 | /** |
||
50 | * |
||
51 | * @param ResponseInterface $response |
||
52 | */ |
||
53 | public function setResponse(ResponseInterface $response) |
||
57 | |||
58 | /** |
||
59 | * |
||
60 | * @return ResponseInterface |
||
61 | */ |
||
62 | public function getResponse() |
||
66 | } |
||
67 |