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() |
||
| 40 | |||
| 41 | /** |
||
| 42 | * Edit the unique page retrieved by slug. |
||
| 43 | * |
||
| 44 | * @param string $slug |
||
| 45 | * @return Response |
||
| 46 | */ |
||
| 47 | public function uniqueEdit($slug) |
||
| 60 | |||
| 61 | /** |
||
| 62 | * Update the unique page. |
||
| 63 | * |
||
| 64 | * @param string $slug |
||
| 65 | * @param int $id |
||
| 66 | * @return \Illuminate\Http\RedirectResponse |
||
| 67 | */ |
||
| 68 | public function update($slug, $id) |
||
| 74 | |||
| 75 | /** |
||
| 76 | * Set the crud route. |
||
| 77 | * |
||
| 78 | * @param $slug |
||
| 79 | */ |
||
| 80 | public function setRoute($slug) |
||
| 84 | |||
| 85 | /** |
||
| 86 | * Populate the update form with basic fields that all pages need. |
||
| 87 | * |
||
| 88 | * @param Model $page |
||
| 89 | */ |
||
| 90 | public function addDefaultPageFields($page) |
||
| 116 | |||
| 117 | /** |
||
| 118 | * Build the buttons html for the edit form. |
||
| 119 | * |
||
| 120 | * @param Model $page |
||
| 121 | * @return string |
||
| 122 | */ |
||
| 123 | public function buttons($page) |
||
| 130 | |||
| 131 | /** |
||
| 132 | * Create the page by slug. |
||
| 133 | * |
||
| 134 | * @param $slug |
||
| 135 | * @return mixed |
||
| 136 | */ |
||
| 137 | public function createMissingPage($slug) |
||
| 155 | |||
| 156 | public function listRevisions() |
||
| 159 | |||
| 160 | /** |
||
| 161 | * Display the revisions for specified resource. |
||
| 162 | * |
||
| 163 | * @param $slug |
||
| 164 | * @param $id |
||
| 165 | * @return Response |
||
| 166 | */ |
||
| 167 | View Code Duplication | public function uniqueRevisions($slug, $id) |
|
| 176 | |||
| 177 | /** |
||
| 178 | * Restore a specific revision for the specified resource. |
||
| 179 | * |
||
| 180 | * Used via AJAX in the revisions view |
||
| 181 | * |
||
| 182 | * @param string $slug |
||
| 183 | * @param int $id |
||
| 184 | * |
||
| 185 | * @return JSON Response containing the new revision that was created from the update |
||
| 186 | * @return HTTP 500 if the request did not contain the revision ID |
||
| 187 | */ |
||
| 188 | View Code Duplication | public function restoreUniqueRevision($slug, $id) |
|
| 197 | |||
| 198 | /** |
||
| 199 | * Setup the controller for the entry. |
||
| 200 | * |
||
| 201 | * @param $entry |
||
| 202 | */ |
||
| 203 | 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 | * |
||
| 240 | * @param [type] $forceSaveAction [description] |
||
| 241 | */ |
||
| 242 | public function setSaveAction($forceSaveAction = null) |
||
| 246 | } |
||
| 247 |
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.