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 CacheLoadAverage 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 |
|
46 | |||
47 | 1 | public function processes(): Processes |
|
51 | |||
52 | 1 | public function loadAverage(): LoadAverage |
|
70 | |||
71 | 1 | public function disk(): Disk |
|
75 | } |
||
76 |