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 |
||
| 38 | class ConsoleOutput implements IOutput { |
||
| 39 | |||
| 40 | /** @var OutputInterface */ |
||
| 41 | private $output; |
||
| 42 | |||
| 43 | /** @var ProgressBar */ |
||
| 44 | private $progressBar; |
||
| 45 | |||
| 46 | public function __construct(OutputInterface $output) { |
||
| 49 | |||
| 50 | /** |
||
| 51 | * @param string $message |
||
| 52 | */ |
||
| 53 | public function info($message) { |
||
| 56 | |||
| 57 | /** |
||
| 58 | * @param string $message |
||
| 59 | */ |
||
| 60 | public function warning($message) { |
||
| 63 | |||
| 64 | /** |
||
| 65 | * @param int $max |
||
| 66 | */ |
||
| 67 | View Code Duplication | public function startProgress($max = 0) { |
|
| 74 | |||
| 75 | /** |
||
| 76 | * @param int $step |
||
| 77 | * @param string $description |
||
| 78 | */ |
||
| 79 | View Code Duplication | public function advance($step = 1, $description = '') { |
|
| 86 | |||
| 87 | public function finishProgress() { |
||
| 93 | } |
||
| 94 |