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 |
||
8 | class EventPanel extends AbstractSubscriablePanel implements IAjaxPanel |
||
9 | { |
||
10 | /** |
||
11 | * $counter. |
||
12 | * |
||
13 | * @var int |
||
14 | */ |
||
15 | protected $counter = 0; |
||
16 | |||
17 | /** |
||
18 | * $totalTime. |
||
19 | * |
||
20 | * @var float |
||
21 | */ |
||
22 | protected $totalTime = 0.0; |
||
23 | |||
24 | /** |
||
25 | * $events. |
||
26 | * |
||
27 | * @var array |
||
28 | */ |
||
29 | protected $events = []; |
||
30 | |||
31 | /** |
||
32 | * getAttributes. |
||
33 | * |
||
34 | * @return array |
||
35 | */ |
||
36 | 2 | public function getAttributes() |
|
44 | |||
45 | /** |
||
46 | * subscribe. |
||
47 | */ |
||
48 | 2 | protected function subscribe() |
|
71 | } |
||
72 |