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 |
||
| 21 | View Code Duplication | final class Linux implements Server |
|
| 22 | { |
||
| 23 | private $cpu; |
||
| 24 | private $memory; |
||
| 25 | private $processes; |
||
| 26 | private $loadAverage; |
||
| 27 | private $disk; |
||
| 28 | |||
| 29 | 7 | public function __construct(TimeContinuumInterface $clock) |
|
| 37 | |||
| 38 | 1 | public function cpu(): Cpu |
|
| 42 | |||
| 43 | 1 | public function memory(): Memory |
|
| 51 | |||
| 52 | 1 | public function loadAverage(): LoadAverage |
|
| 56 | |||
| 57 | 1 | public function disk(): Disk |
|
| 61 | } |
||
| 62 |