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 |
||
17 | View Code Duplication | class PostCommandEvent extends Event |
|
18 | { |
||
19 | /** @var CommandInterface */ |
||
20 | private $command; |
||
21 | |||
22 | /** @var ResponseInterface */ |
||
23 | private $response; |
||
24 | |||
25 | /** |
||
26 | * |
||
27 | * @param CommandInterface $command |
||
28 | * @param ResponseInterface $response |
||
29 | */ |
||
30 | public function __construct(CommandInterface $command, ResponseInterface $response) |
||
35 | |||
36 | /** |
||
37 | * |
||
38 | * @return CommandInterface |
||
39 | */ |
||
40 | public function getCommand() |
||
44 | |||
45 | /** |
||
46 | * |
||
47 | * @return ResponseInterface |
||
48 | */ |
||
49 | public function getResponse() |
||
53 | } |
||
54 |