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 |
||
14 | class DockerComposeTransport implements TransportInterface |
||
15 | { |
||
16 | protected $tty; |
||
17 | protected $siteAlias; |
||
18 | protected $cd_remote; |
||
19 | |||
20 | public function __construct(SiteAliasInterface $siteAlias) |
||
24 | |||
25 | /** |
||
26 | * @inheritdoc |
||
27 | */ |
||
28 | public function configure(SiteProcess $process) |
||
32 | |||
33 | /** |
||
34 | * @inheritdoc |
||
35 | */ |
||
36 | View Code Duplication | public function wrap($args) |
|
48 | |||
49 | /** |
||
50 | * @inheritdoc |
||
51 | */ |
||
52 | public function addChdir($cd, $args) |
||
57 | |||
58 | /** |
||
59 | * getTransport returns the transport along with the docker-compose |
||
60 | * project in case it is defined. |
||
61 | */ |
||
62 | protected function getTransport() |
||
75 | |||
76 | /** |
||
77 | * getTransportOptions returns the transport options for the tranport |
||
78 | * mechanism itself |
||
79 | */ |
||
80 | protected function getTransportOptions() |
||
96 | |||
97 | /** |
||
98 | * getCommandToExecute processes the arguments for the command to |
||
99 | * be executed such that they are appropriate for the transport mechanism. |
||
100 | * |
||
101 | * Nothing to do for this transport. |
||
102 | */ |
||
103 | protected function getCommandToExecute($args) |
||
107 | } |
||
108 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.