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 |
||
14 | class FileUploadPagePartTest extends TestCase |
||
15 | { |
||
16 | /** |
||
17 | * @var FileUploadPagePart |
||
18 | */ |
||
19 | protected $object; |
||
20 | |||
21 | /** |
||
22 | * Sets up the fixture, for example, opens a network connection. |
||
23 | * This method is called before a test is executed. |
||
24 | */ |
||
25 | protected function setUp() |
||
29 | |||
30 | View Code Duplication | public function testAdaptForm() |
|
52 | |||
53 | public function testGetDefaultView() |
||
59 | |||
60 | public function testGetDefaultAdminType() |
||
64 | |||
65 | public function testGetSetRequired() |
||
71 | } |
||
72 |
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.