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 |
||
10 | View Code Duplication | final class MysqlConnectionSpeed implements Measurement |
|
11 | { |
||
12 | /** |
||
13 | * @var Manager |
||
14 | */ |
||
15 | private $manager; |
||
16 | |||
17 | public function __construct(Manager $manager) |
||
21 | |||
22 | /** |
||
23 | * The name of the. |
||
24 | * |
||
25 | * @return string |
||
26 | */ |
||
27 | public function name(): string |
||
31 | |||
32 | /** |
||
33 | * Runs the measurement. |
||
34 | * |
||
35 | * @param MeasurementStore $store |
||
36 | * @param array $data |
||
37 | */ |
||
38 | public function run(MeasurementStore $store, array $data) |
||
52 | } |
||
53 |