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 |
||
| 19 | View Code Duplication | final class CacheMemory implements Server |
|
| 20 | { |
||
| 21 | private $server; |
||
| 22 | private $clock; |
||
| 23 | private $threshold; |
||
| 24 | private $cachedAt; |
||
| 25 | private $data; |
||
| 26 | |||
| 27 | 6 | public function __construct( |
|
| 36 | |||
| 37 | 1 | public function cpu(): Cpu |
|
| 41 | |||
| 42 | 1 | public function memory(): Memory |
|
| 60 | |||
| 61 | 1 | public function processes(): Processes |
|
| 65 | |||
| 66 | 1 | public function loadAverage(): LoadAverage |
|
| 70 | |||
| 71 | 1 | public function disk(): Disk |
|
| 75 | } |
||
| 76 |