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 |
||
31 | View Code Duplication | class LatestMessageTest extends MessageTestCase |
|
32 | { |
||
33 | /** |
||
34 | * testConstructor |
||
35 | */ |
||
36 | public function testConstructor() |
||
41 | |||
42 | /** |
||
43 | * getClassName must return a string with the FQN of the command class being tested |
||
44 | * @return string |
||
45 | */ |
||
46 | protected function getClassName() |
||
50 | |||
51 | /** |
||
52 | * Must return an array in the format: |
||
53 | * |
||
54 | * [ |
||
55 | * 'name' => 'functionName', // required |
||
56 | * 'with' => [arguments for with] // optional |
||
57 | * 'return' => return value // optional, defaults to return self |
||
58 | * 'times' => number of times it will be invoked |
||
59 | * ] |
||
60 | * |
||
61 | * @return array |
||
62 | */ |
||
63 | protected function getExpectations() |
||
74 | } |
||
75 |