We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Conditions | 1 |
| Paths | 1 |
| Total Lines | 56 |
| Code Lines | 36 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 15 | public function __construct($name, $controller, $options) |
||
| 16 | { |
||
| 17 | $this->name = $name; |
||
| 18 | $this->options = $options; |
||
| 19 | $this->controller = $controller; |
||
| 20 | |||
| 21 | // CRUD routes |
||
| 22 | Route::post($this->name.'/search', [ |
||
| 23 | 'as' => 'crud.'.$this->name.'.search', |
||
| 24 | 'uses' => $this->controller.'@search', |
||
| 25 | ]); |
||
| 26 | |||
| 27 | Route::get($this->name.'/reorder', [ |
||
| 28 | 'as' => 'crud.'.$this->name.'.reorder', |
||
| 29 | 'uses' => $this->controller.'@reorder', |
||
| 30 | ]); |
||
| 31 | |||
| 32 | Route::post($this->name.'/reorder', [ |
||
| 33 | 'as' => 'crud.'.$this->name.'.save.reorder', |
||
| 34 | 'uses' => $this->controller.'@saveReorder', |
||
| 35 | ]); |
||
| 36 | |||
| 37 | Route::get($this->name.'/{id}/details', [ |
||
| 38 | 'as' => 'crud.'.$this->name.'.showDetailsRow', |
||
| 39 | 'uses' => $this->controller.'@showDetailsRow', |
||
| 40 | ]); |
||
| 41 | |||
| 42 | Route::get($this->name.'/{id}/translate/{lang}', [ |
||
| 43 | 'as' => 'crud.'.$this->name.'.translateItem', |
||
| 44 | 'uses' => $this->controller.'@translateItem', |
||
| 45 | ]); |
||
| 46 | |||
| 47 | Route::get($this->name.'/{id}/revisions', [ |
||
| 48 | 'as' => 'crud.'.$this->name.'.listRevisions', |
||
| 49 | 'uses' => $this->controller.'@listRevisions', |
||
| 50 | ]); |
||
| 51 | |||
| 52 | Route::post($this->name.'/{id}/revisions/{revisionId}/restore', [ |
||
| 53 | 'as' => 'crud.'.$this->name.'.restoreRevision', |
||
| 54 | 'uses' => $this->controller.'@restoreRevision', |
||
| 55 | ]); |
||
| 56 | |||
| 57 | $options_with_default_route_names = array_merge([ |
||
| 58 | 'names' => [ |
||
| 59 | 'index' => 'crud.'.$this->name.'.index', |
||
| 60 | 'create' => 'crud.'.$this->name.'.create', |
||
| 61 | 'store' => 'crud.'.$this->name.'.store', |
||
| 62 | 'edit' => 'crud.'.$this->name.'.edit', |
||
| 63 | 'update' => 'crud.'.$this->name.'.update', |
||
| 64 | 'show' => 'crud.'.$this->name.'.show', |
||
| 65 | 'destroy' => 'crud.'.$this->name.'.destroy', |
||
| 66 | ], |
||
| 67 | ], $this->options); |
||
| 68 | |||
| 69 | Route::resource($this->name, $this->controller, $options_with_default_route_names); |
||
| 70 | } |
||
| 71 | |||
| 109 |