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 |
||
13 | class InstallController |
||
14 | { |
||
15 | |||
16 | /** @var \Buttress\Concrete\Console\Command\PackageCommand */ |
||
17 | private $command; |
||
18 | |||
19 | /** @var \League\Tactician\CommandBus */ |
||
20 | private $bus; |
||
21 | |||
22 | /** @var \League\CLImate\CLImate */ |
||
23 | private $cli; |
||
24 | |||
25 | public function __construct(PackageCommand $command, CommandBus $bus, CLImate $cli) |
||
31 | |||
32 | /** |
||
33 | * Handle package:list |
||
34 | * |
||
35 | * @param \Buttress\Concrete\Locator\Site $site |
||
36 | */ |
||
37 | public function listPackages(Site $site) |
||
42 | |||
43 | /** |
||
44 | * Handle package:install |
||
45 | * |
||
46 | * @param \Buttress\Concrete\Locator\Site $site |
||
47 | */ |
||
48 | View Code Duplication | public function install(Site $site) |
|
67 | |||
68 | /** |
||
69 | * Handle package:uninstall |
||
70 | * |
||
71 | * @param \Buttress\Concrete\Locator\Site $site |
||
72 | */ |
||
73 | View Code Duplication | public function uninstall(Site $site) |
|
92 | |||
93 | private function getDefinition(Site $site, $command) |
||
103 | |||
104 | private function getAvailablePackages(Site $site) |
||
114 | |||
115 | private function confirmHandle($packages) |
||
125 | |||
126 | } |
||
127 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.