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) |
||
| 72 | |||
| 73 | /** |
||
| 74 | * @param TimeToFirstByte $maxTimeToFirstByte |
||
| 75 | * @param Result $result |
||
| 76 | */ |
||
| 77 | protected function assertTimeToFirstByteBelow(TimeToFirstByte $maxTimeToFirstByte, Result $result) |
||
| 90 | |||
| 91 | /** |
||
| 92 | * @param Result $result |
||
| 93 | */ |
||
| 94 | protected function assertBodyNotEmpty(Result $result) |
||
| 103 | |||
| 104 | /** |
||
| 105 | * @param HeaderKey $key |
||
| 106 | * @param Result $result |
||
| 107 | */ |
||
| 108 | View Code Duplication | protected function assertHasHeaderKey(HeaderKey $key, Result $result) |
|
| 118 | |||
| 119 | /** |
||
| 120 | * @param Header $searchHeader |
||
| 121 | * @param Result $result |
||
| 122 | */ |
||
| 123 | View Code Duplication | protected function assertHasHeader(Header $searchHeader, Result $result) |
|
| 133 | |||
| 134 | /** |
||
| 135 | * @param Header $searchHeader |
||
| 136 | * @param Result $result |
||
| 137 | */ |
||
| 138 | protected function assertNotHasHeader(Header $searchHeader, Result $result) |
||
| 147 | } |
||
| 148 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.