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 |
||
9 | abstract class AbstractListTest extends TestCase |
||
10 | { |
||
11 | /** |
||
12 | * @test |
||
13 | * @dataProvider getValidParameters |
||
14 | */ |
||
15 | public function construct_validConstructorParameters_newListCreatedWithNoExceptions(array $parameters): void |
||
28 | |||
29 | /** |
||
30 | * @test |
||
31 | * @dataProvider getInvalidParameters |
||
32 | */ |
||
33 | View Code Duplication | public function construct_invalidConstructorParameters_invalidTypeExceptionThrowed(array $parameters): void |
|
46 | |||
47 | /** |
||
48 | * @test |
||
49 | * @dataProvider getValidParameters |
||
50 | */ |
||
51 | public function add_validParameters_noExceptions(array $parameters): void |
||
65 | |||
66 | /** |
||
67 | * @test |
||
68 | * @dataProvider getInvalidParameters |
||
69 | */ |
||
70 | View Code Duplication | public function add_invalidParameters_noExceptions(array $parameters): void |
|
84 | |||
85 | /** |
||
86 | * @test |
||
87 | * @dataProvider getValidParameters |
||
88 | */ |
||
89 | public function set_validParameters_noExceptions(array $parameters): void |
||
104 | |||
105 | /** |
||
106 | * @test |
||
107 | * @dataProvider getInvalidParameters |
||
108 | */ |
||
109 | View Code Duplication | public function set_invalidParameters_noExceptions(array $parameters): void |
|
123 | |||
124 | protected function createList(array $parameters = []): AbstractTypedList |
||
130 | |||
131 | abstract protected function getListClassName(): string; |
||
132 | } |
||
133 |