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 |
||
13 | trait SmokeTestTrait |
||
14 | { |
||
15 | /** |
||
16 | * @param Result $result |
||
17 | */ |
||
18 | public function successOutput(Result $result) |
||
22 | |||
23 | /** |
||
24 | * @param Result $result |
||
25 | */ |
||
26 | public function errorOutput(Result $result) |
||
30 | |||
31 | /** |
||
32 | * @param SmokeTestOptions $smokeTestOptions |
||
33 | * |
||
34 | * @return array |
||
35 | */ |
||
36 | protected function runSmokeTests(SmokeTestOptions $smokeTestOptions) |
||
58 | |||
59 | /** |
||
60 | * @param Result $result |
||
61 | */ |
||
62 | protected function assertSuccess(Result $result) |
||
69 | |||
70 | /** |
||
71 | * @param TimeToFirstByte $maxTimeToFirstByte |
||
72 | * @param Result $result |
||
73 | */ |
||
74 | protected function assertTimeToFirstByteBelow(TimeToFirstByte $maxTimeToFirstByte, Result $result) |
||
84 | |||
85 | /** |
||
86 | * @param Result $result |
||
87 | */ |
||
88 | protected function assertBodyNotEmpty(Result $result) |
||
94 | |||
95 | /** |
||
96 | * @param HeaderKey $key |
||
97 | * @param Result $result |
||
98 | */ |
||
99 | View Code Duplication | protected function assertHeaderKeyExists(HeaderKey $key, Result $result) |
|
106 | |||
107 | /** |
||
108 | * @param Header $searchHeader |
||
109 | * @param Result $result |
||
110 | */ |
||
111 | View Code Duplication | protected function assertHeaderExists(Header $searchHeader, Result $result) |
|
118 | } |
||
119 |