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 |
||
19 | class WorkflowConfigTest extends TestCase |
||
20 | { |
||
21 | use HttpMockTrait; |
||
22 | |||
23 | /** |
||
24 | * @var WorkflowConfig |
||
25 | */ |
||
26 | private $workflowConfig; |
||
27 | |||
28 | |||
29 | /** |
||
30 | * @var string |
||
31 | */ |
||
32 | private static $exampleWorkflowConfig; |
||
33 | |||
34 | /** |
||
35 | * Путь до файла с тестовым workflow |
||
36 | * |
||
37 | * @var string |
||
38 | */ |
||
39 | private static $pathToExampleWorkflowConfig; |
||
40 | |||
41 | /** |
||
42 | * @return void |
||
43 | */ |
||
44 | View Code Duplication | public static function setUpBeforeClass() |
|
56 | |||
57 | /** |
||
58 | * |
||
59 | */ |
||
60 | public static function tearDownAfterClass() |
||
64 | |||
65 | /** |
||
66 | * |
||
67 | */ |
||
68 | public function tearDown() |
||
72 | |||
73 | /** |
||
74 | * @return void |
||
75 | */ |
||
76 | protected function setUp() |
||
84 | |||
85 | /** |
||
86 | * Тестируем установку корректных св-тв при передаче корректного файла |
||
87 | */ |
||
88 | public function testCorrectSetFileType() |
||
97 | |||
98 | |||
99 | /** |
||
100 | * Тестируем установку корректных св-тв при передаче корректного урл |
||
101 | */ |
||
102 | public function testCorrectSetUrlType() |
||
130 | |||
131 | |||
132 | /** |
||
133 | * Тестируем установку корректных св-тв в случае если не указан тип ресурса |
||
134 | */ |
||
135 | public function testCorrectSetDefaultType() |
||
145 | |||
146 | /** |
||
147 | * Тестируем установку имени класса реализующего обертку для uri |
||
148 | */ |
||
149 | View Code Duplication | public function testGetterSetterUriClassName() |
|
159 | } |
||
160 |
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.