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 |
||
8 | class ContainerTest extends TestCase |
||
9 | { |
||
10 | /** @test */ |
||
11 | public function it_has_a_base_path_getter() |
||
18 | |||
19 | /** @test */ |
||
20 | public function it_has_a_config_path_getter() |
||
27 | |||
28 | /** @test */ |
||
29 | View Code Duplication | public function it_has_a_database_path_getter() |
|
40 | |||
41 | /** @test */ |
||
42 | public function it_has_a_lang_path_getter() |
||
46 | |||
47 | /** @test */ |
||
48 | public function it_has_a_storage_path_getter() |
||
52 | |||
53 | /** @test */ |
||
54 | View Code Duplication | public function it_has_a_resource_path_getter() |
|
62 | } |
||
63 |
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.