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 |
||
20 | View Code Duplication | class TeamModeTest extends UnitTestCase |
|
|
|||
21 | { |
||
22 | //<editor-fold desc="Public Methods"> |
||
23 | |||
24 | /** |
||
25 | * @covers \Tfboe\FmLib\Entity\CategoryTraits\TeamMode::getTeamMode |
||
26 | * @covers \Tfboe\FmLib\Entity\CategoryTraits\TeamMode::setTeamMode |
||
27 | * @uses \Tfboe\FmLib\Helpers\BasicEnum |
||
28 | */ |
||
29 | public function testProperty() |
||
40 | |||
41 | /** |
||
42 | * @covers \Tfboe\FmLib\Entity\CategoryTraits\TeamMode::setTeamMode |
||
43 | * @uses \Tfboe\FmLib\Helpers\BasicEnum |
||
44 | * @uses \Tfboe\FmLib\Exceptions\ValueNotValid::__construct |
||
45 | */ |
||
46 | public function testPropertyException() |
||
55 | //</editor-fold desc="Public Methods"> |
||
56 | |||
57 | //<editor-fold desc="Private Methods"> |
||
58 | /** |
||
59 | * @return \PHPUnit_Framework_MockObject_MockObject|\Tfboe\FmLib\Entity\CategoryTraits\TeamMode |
||
60 | */ |
||
61 | private function mock(): \PHPUnit_Framework_MockObject_MockObject |
||
65 | //</editor-fold desc="Private Methods"> |
||
66 | } |
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.