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 |
||
11 | class UniquePageCrudController extends CrudController |
||
12 | { |
||
13 | use SaveActions; |
||
14 | use UniquePages; |
||
15 | use TraitReflections; |
||
16 | |||
17 | public function setup() |
||
39 | |||
40 | /** |
||
41 | * Edit the unique page retrieved by slug. |
||
42 | * |
||
43 | * @param string $slug |
||
44 | * @return Response |
||
|
|||
45 | */ |
||
46 | public function uniqueEdit($slug) |
||
59 | |||
60 | /** |
||
61 | * Update the unique page. |
||
62 | * |
||
63 | * @param string $slug |
||
64 | * @param int $id |
||
65 | * @return \Illuminate\Http\RedirectResponse |
||
66 | */ |
||
67 | View Code Duplication | public function update($slug, $id) |
|
76 | |||
77 | /** |
||
78 | * Set the crud route. |
||
79 | * |
||
80 | * @param $slug |
||
81 | */ |
||
82 | public function setRoute($slug) |
||
86 | |||
87 | /** |
||
88 | * Populate the update form with basic fields that all pages need. |
||
89 | * |
||
90 | * @param Model $page |
||
91 | */ |
||
92 | public function addDefaultPageFields($page) |
||
118 | |||
119 | /** |
||
120 | * Build the buttons html for the edit form. |
||
121 | * |
||
122 | * @param Model $page |
||
123 | * @return string |
||
124 | */ |
||
125 | public function buttons($page) |
||
132 | |||
133 | /** |
||
134 | * Create missing unique page by slug. |
||
135 | * |
||
136 | * @param $slug |
||
137 | * @return mixed |
||
138 | */ |
||
139 | public function createMissingPage($slug) |
||
157 | |||
158 | /** |
||
159 | * Display the revisions for specified resource. |
||
160 | * |
||
161 | * @param $slug |
||
162 | * @param $id |
||
163 | * @return Response |
||
164 | */ |
||
165 | View Code Duplication | public function uniqueRevisions($slug, $id) |
|
174 | |||
175 | /** |
||
176 | * Restore a specific revision for the specified resource. |
||
177 | * |
||
178 | * Used via AJAX in the revisions view |
||
179 | * |
||
180 | * @param string $slug |
||
181 | * @param int $id |
||
182 | * |
||
183 | * @return JSON Response containing the new revision that was created from the update |
||
184 | * @return HTTP 500 if the request did not contain the revision ID |
||
185 | */ |
||
186 | View Code Duplication | public function restoreUniqueRevision($slug, $id) |
|
195 | |||
196 | /** |
||
197 | * Setup the controller for the entry. |
||
198 | * |
||
199 | * @param $entry |
||
200 | */ |
||
201 | protected function uniqueSetup($entry) |
||
212 | |||
213 | /* |
||
214 | |-------------------------------------------------------------------------- |
||
215 | | SaveActions overrides |
||
216 | |-------------------------------------------------------------------------- |
||
217 | */ |
||
218 | |||
219 | /** |
||
220 | * Overrides trait version to remove 'save_and_back' and 'save_and_new'. |
||
221 | * |
||
222 | * @return [type] [description] |
||
223 | */ |
||
224 | public function getSaveAction() |
||
236 | |||
237 | /** |
||
238 | * Override trait version to not update the session variable. |
||
239 | * This way we preserve the user chosen save action and don't overwrite with |
||
240 | * |
||
241 | * @param [type] $forceSaveAction [description] |
||
242 | */ |
||
243 | public function setSaveAction($forceSaveAction = null) |
||
247 | } |
||
248 |
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.