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_CustomerAddress |
|
|
|||
15 | extends IntegerNet_Anonymizer_Test_Model_Bridge_Entity_Abstract |
||
16 | { |
||
17 | /** |
||
18 | * @param $customerAddressId |
||
19 | * @test |
||
20 | * @dataProvider dataProvider |
||
21 | * @dataProviderFile testCustomerAddressBridge.yaml |
||
22 | * @loadExpectation bridge.yaml |
||
23 | * @loadFixture customers.yaml |
||
24 | */ |
||
25 | public function testGetValues($customerAddressId) |
||
35 | |||
36 | /** |
||
37 | * @param $customerAddressId |
||
38 | * @test |
||
39 | * @dataProvider dataProvider |
||
40 | * @dataProviderFile testCustomerAddressBridge.yaml |
||
41 | * @loadFixture customers.yaml |
||
42 | */ |
||
43 | public function testUpdateValues($customerAddressId) |
||
63 | |||
64 | |||
65 | } |
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.