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 | class EvidenceListTest extends FlexiBeeROTest |
||
11 | { |
||
12 | /** |
||
13 | * @var EvidenceList |
||
14 | */ |
||
15 | protected $object; |
||
16 | |||
17 | /** |
||
18 | * Sets up the fixture, for example, opens a network connection. |
||
19 | * This method is called before a test is executed. |
||
20 | */ |
||
21 | protected function setUp() |
||
25 | |||
26 | /** |
||
27 | * |
||
28 | */ |
||
29 | public function checkLists() |
||
34 | |||
35 | /** |
||
36 | * @covers FlexiPeeHP\EvidenceList::objectToID |
||
37 | */ |
||
38 | View Code Duplication | public function testObjectToID() |
|
45 | |||
46 | /** |
||
47 | * @covers FlexiPeeHP\EvidenceList::__toString |
||
48 | */ |
||
49 | public function testtoString() |
||
53 | |||
54 | /** |
||
55 | * @covers FlexiPeeHP\EvidenceList::draw |
||
56 | */ |
||
57 | public function testDraw($whatWant = NULL) |
||
61 | |||
62 | /** |
||
63 | * @covers FlexiPeeHP\EvidenceList::getMyKey |
||
64 | * |
||
65 | * @todo Implement testGetMyKey(). |
||
66 | */ |
||
67 | public function testGetMyKey() |
||
71 | |||
72 | /** |
||
73 | * Tears down the fixture, for example, closes a network connection. |
||
74 | * This method is called after a test is executed. |
||
75 | */ |
||
76 | protected function tearDown() |
||
80 | } |
||
81 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.