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 OfxParseTest extends PHPUnit_Framework_TestCase |
||
15 | { |
||
16 | |||
17 | /** |
||
18 | * @test |
||
19 | * @expectedException Exception |
||
20 | */ |
||
21 | public function wrongXmlFormat() |
||
26 | |||
27 | /** |
||
28 | * @test |
||
29 | */ |
||
30 | View Code Duplication | public function itau() |
|
37 | |||
38 | /** |
||
39 | * @test |
||
40 | */ |
||
41 | View Code Duplication | public function santander() |
|
48 | |||
49 | /** |
||
50 | * @test |
||
51 | */ |
||
52 | View Code Duplication | public function caixa() |
|
59 | |||
60 | /** |
||
61 | * @test |
||
62 | */ |
||
63 | View Code Duplication | public function faturaCC() |
|
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.