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 | View Code Duplication | class IntegerNet_Anonymizer_Test_Model_Bridge_Entity_GiftregistryPerson |
|
|
|||
15 | extends IntegerNet_Anonymizer_Test_Model_Bridge_Entity_Abstract |
||
16 | { |
||
17 | /** |
||
18 | * @test |
||
19 | */ |
||
20 | public function isEnterprise() |
||
26 | |||
27 | /** |
||
28 | * @param $personId |
||
29 | * @test |
||
30 | * @depends isEnterprise |
||
31 | * @dataProvider dataProvider |
||
32 | * @dataProviderFile testGiftregistryPersonBridge.yaml |
||
33 | * @loadExpectation bridge.yaml |
||
34 | * @loadFixture customers.yaml |
||
35 | * @loadFixture enterprise.yaml |
||
36 | */ |
||
37 | public function testGetValues($personId) |
||
47 | |||
48 | /** |
||
49 | * @param $registryId |
||
50 | * @test |
||
51 | * @depends isEnterprise |
||
52 | * @dataProvider dataProvider |
||
53 | * @dataProviderFile testGiftregistryPersonBridge.yaml |
||
54 | * @loadFixture customers.yaml |
||
55 | * @loadFixture enterprise.yaml |
||
56 | */ |
||
57 | public function testUpdateValues($registryId) |
||
73 | } |
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.