We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
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 | class CrudPanelCreateTest extends BaseDBCrudPanelTest |
||
10 | { |
||
11 | private $nonRelationshipField = [ |
||
12 | 'name' => 'field1', |
||
13 | 'label' => 'Field1', |
||
14 | ]; |
||
15 | |||
16 | private $userInputFieldsNoRelationships = [ |
||
17 | [ |
||
18 | 'name' => 'id', |
||
19 | 'type' => 'hidden', |
||
20 | ], [ |
||
21 | 'name' => 'name', |
||
22 | ], [ |
||
23 | 'name' => 'email', |
||
24 | 'type' => 'email', |
||
25 | ], [ |
||
26 | 'name' => 'password', |
||
27 | 'type' => 'password', |
||
28 | ], |
||
29 | ]; |
||
30 | |||
31 | private $articleInputFieldsOneToMany = [ |
||
32 | [ |
||
33 | 'name' => 'id', |
||
34 | 'type' => 'hidden', |
||
35 | ], [ |
||
36 | 'name' => 'content', |
||
37 | ], [ |
||
38 | 'name' => 'tags', |
||
39 | ], [ |
||
40 | 'label' => 'Author', |
||
41 | 'type' => 'select', |
||
42 | 'name' => 'user_id', |
||
43 | 'entity' => 'user', |
||
44 | 'attribute' => 'name', |
||
45 | ], |
||
46 | ]; |
||
47 | |||
48 | private $userInputFieldsManyToMany = [ |
||
49 | [ |
||
50 | 'name' => 'id', |
||
51 | 'type' => 'hidden', |
||
52 | ], [ |
||
53 | 'name' => 'name', |
||
54 | ], [ |
||
55 | 'name' => 'email', |
||
56 | 'type' => 'email', |
||
57 | ], [ |
||
58 | 'name' => 'password', |
||
59 | 'type' => 'password', |
||
60 | ], [ |
||
61 | 'label' => 'Roles', |
||
62 | 'type' => 'select_multiple', |
||
63 | 'name' => 'roles', |
||
64 | 'entity' => 'roles', |
||
65 | 'attribute' => 'name', |
||
66 | 'pivot' => true, |
||
67 | ], |
||
68 | ]; |
||
69 | |||
70 | private $userInputFieldsDotNotation = [ |
||
71 | [ |
||
72 | 'name' => 'id', |
||
73 | 'type' => 'hidden', |
||
74 | ], [ |
||
75 | 'name' => 'name', |
||
76 | ], [ |
||
77 | 'name' => 'email', |
||
78 | 'type' => 'email', |
||
79 | ], [ |
||
80 | 'name' => 'password', |
||
81 | 'type' => 'password', |
||
82 | ], [ |
||
83 | 'label' => 'Roles', |
||
84 | 'type' => 'select_multiple', |
||
85 | 'name' => 'roles', |
||
86 | 'entity' => 'roles', |
||
87 | 'attribute' => 'name', |
||
88 | 'pivot' => true, |
||
89 | ], [ |
||
90 | 'label' => 'Street', |
||
91 | 'name' => 'street', |
||
92 | 'entity' => 'accountDetails.addresses', |
||
93 | 'attribute' => 'street', |
||
94 | ], |
||
95 | ]; |
||
96 | |||
97 | public function testCreate() |
||
114 | |||
115 | public function testCreateWithOneToOneRelationship() |
||
119 | |||
120 | public function testCreateWithOneToManyRelationship() |
||
139 | |||
140 | public function testCreateWithManyToManyRelationship() |
||
158 | |||
159 | View Code Duplication | public function testGetRelationFields() |
|
172 | |||
173 | View Code Duplication | public function testGetRelationFieldsCreateForm() |
|
182 | |||
183 | View Code Duplication | public function testGetRelationFieldsUpdateForm() |
|
192 | |||
193 | public function testGetRelationFieldsUnknownForm() |
||
206 | |||
207 | View Code Duplication | public function testGetRelationFieldsDotNotation() |
|
216 | |||
217 | public function testGetRelationFieldsNoRelations() |
||
225 | |||
226 | public function testGetRelationFieldsNoFields() |
||
232 | |||
233 | View Code Duplication | public function testGetRelationFieldsWithPivot() |
|
242 | |||
243 | public function testGetRelationFieldsWithPivotNoRelations() |
||
252 | |||
253 | View Code Duplication | public function testSyncPivot() |
|
271 | |||
272 | View Code Duplication | public function testSyncPivotUnknownData() |
|
290 | |||
291 | public function testSyncPivotUnknownModel() |
||
309 | } |
||
310 |
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.