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 ProcessRunner |
||
| 15 | { |
||
| 16 | /** |
||
| 17 | * @var ProcessOutputPrinter |
||
| 18 | */ |
||
| 19 | private $pop; |
||
| 20 | |||
| 21 | public function __construct(ProcessOutputPrinter $pop) |
||
| 25 | |||
| 26 | /** |
||
| 27 | * Runs a command, consider deployer global configs (timeout,...) |
||
| 28 | * |
||
| 29 | * @param string $hostname |
||
| 30 | * @param string $command |
||
| 31 | * @param array $config |
||
| 32 | * |
||
| 33 | * @return string |
||
| 34 | * |
||
| 35 | * @throws ProcessFailedException When the process does not return a 0 exit code. |
||
| 36 | */ |
||
| 37 | public function run($hostname, string $command, array $config = []) |
||
| 59 | } |
||
| 60 |