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 |
||
| 10 | class UniquePageCrudController extends CrudController |
||
| 11 | { |
||
| 12 | use SaveActions; |
||
| 13 | use UniquePages; |
||
| 14 | use TraitReflections; |
||
| 15 | |||
| 16 | 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 | public function update($slug, $id) |
||
| 73 | |||
| 74 | /** |
||
| 75 | * Set the crud route. |
||
| 76 | * |
||
| 77 | * @param $slug |
||
| 78 | */ |
||
| 79 | public function setRoute($slug) |
||
| 83 | |||
| 84 | /** |
||
| 85 | * Populate the update form with basic fields that all pages need. |
||
| 86 | * |
||
| 87 | * @param Model $page |
||
| 88 | */ |
||
| 89 | public function addDefaultPageFields($page) |
||
| 115 | |||
| 116 | /** |
||
| 117 | * Build the buttons html for the edit form. |
||
| 118 | * |
||
| 119 | * @param Model $page |
||
| 120 | * @return string |
||
| 121 | */ |
||
| 122 | public function buttons($page) |
||
| 129 | |||
| 130 | /** |
||
| 131 | * Create the page by slug. |
||
| 132 | * |
||
| 133 | * @param $slug |
||
| 134 | * @return mixed |
||
| 135 | */ |
||
| 136 | public function createMissingPage($slug) |
||
| 154 | |||
| 155 | /** |
||
| 156 | * Display the revisions for specified resource. |
||
| 157 | * |
||
| 158 | * @param $slug |
||
| 159 | * @param $id |
||
| 160 | * @return Response |
||
| 161 | */ |
||
| 162 | View Code Duplication | public function uniqueRevisions($slug, $id) |
|
| 171 | |||
| 172 | /** |
||
| 173 | * Restore a specific revision for the specified resource. |
||
| 174 | * |
||
| 175 | * Used via AJAX in the revisions view |
||
| 176 | * |
||
| 177 | * @param string $slug |
||
| 178 | * @param int $id |
||
| 179 | * |
||
| 180 | * @return JSON Response containing the new revision that was created from the update |
||
| 181 | * @return HTTP 500 if the request did not contain the revision ID |
||
| 182 | */ |
||
| 183 | View Code Duplication | public function restoreUniqueRevision($slug, $id) |
|
| 192 | |||
| 193 | /** |
||
| 194 | * Setup the controller for the entry. |
||
| 195 | * |
||
| 196 | * @param $entry |
||
| 197 | */ |
||
| 198 | protected function uniqueSetup($entry) |
||
| 207 | |||
| 208 | /* |
||
| 209 | |-------------------------------------------------------------------------- |
||
| 210 | | SaveActions overrides |
||
| 211 | |-------------------------------------------------------------------------- |
||
| 212 | */ |
||
| 213 | |||
| 214 | /** |
||
| 215 | * Overrides trait version to remove 'save_and_back' and 'save_and_new'. |
||
| 216 | * |
||
| 217 | * @return [type] [description] |
||
| 218 | */ |
||
| 219 | public function getSaveAction() |
||
| 231 | |||
| 232 | /** |
||
| 233 | * Override trait version to not update the session variable. |
||
| 234 | * |
||
| 235 | * @param [type] $forceSaveAction [description] |
||
| 236 | */ |
||
| 237 | public function setSaveAction($forceSaveAction = null) |
||
| 241 | } |
||
| 242 |
This check looks for a call to a parent method whose name is different than the method from which it is called.
Consider the following code:
The
getFirstName()method in theSoncalls the wrong method in the parent class.