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 |
||
9 | View Code Duplication | class xsGYearMonthTest extends \PHPUnit_Framework_TestCase |
|
|
|||
10 | { |
||
11 | /** |
||
12 | * @var \AlgoWeb\xsdTypes\xsGYearMonth |
||
13 | */ |
||
14 | protected $object; |
||
15 | |||
16 | /** |
||
17 | * Sets up the fixture, for example, opens a network connection. |
||
18 | * This method is called before a test is executed. |
||
19 | */ |
||
20 | protected function setUp() |
||
25 | |||
26 | /** |
||
27 | * Tears down the fixture, for example, closes a network connection. |
||
28 | * This method is called after a test is executed. |
||
29 | */ |
||
30 | protected function tearDown() |
||
34 | |||
35 | /** |
||
36 | * @covers \AlgoWeb\xsdTypes\xsGYearMonth::fixValue |
||
37 | * @todo Implement testFixValue(). |
||
38 | */ |
||
39 | public function testFixValue() |
||
46 | |||
47 | |||
48 | /** |
||
49 | * @covers \AlgoWeb\xsdTypes\xsGYearMonth::__toString |
||
50 | * @todo Implement test__toString(). |
||
51 | */ |
||
52 | public function test__toString() |
||
59 | |||
60 | |||
61 | /** |
||
62 | * @covers \AlgoWeb\xsdTypes\xsGYearMonth::setMaxExclusive |
||
63 | * @todo Implement testSetMaxExclusive(). |
||
64 | */ |
||
65 | public function testSetMaxExclusive() |
||
72 | |||
73 | |||
74 | /** |
||
75 | * @covers \AlgoWeb\xsdTypes\xsGYearMonth::setMaxInclusive |
||
76 | * @todo Implement testSetMaxInclusive(). |
||
77 | */ |
||
78 | public function testSetMaxInclusive() |
||
85 | |||
86 | |||
87 | /** |
||
88 | * @covers \AlgoWeb\xsdTypes\xsGYearMonth::setMinExclusive |
||
89 | * @todo Implement testSetMinExclusive(). |
||
90 | */ |
||
91 | public function testSetMinExclusive() |
||
98 | |||
99 | |||
100 | /** |
||
101 | * @covers \AlgoWeb\xsdTypes\xsGYearMonth::setMinInclusive |
||
102 | * @todo Implement testSetMinInclusive(). |
||
103 | */ |
||
104 | public function testSetMinInclusive() |
||
111 | |||
112 | |||
113 | /** |
||
114 | * @covers \AlgoWeb\xsdTypes\xsGYearMonth::checkMinMax |
||
115 | * @todo Implement testCheckMinMax(). |
||
116 | */ |
||
117 | public function testCheckMinMax() |
||
124 | } |
||
125 |
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.