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 | 53 |
| Code Lines | 18 |
| 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 setup($template_name = false) |
||
| 16 | { |
||
| 17 | parent::__construct(); |
||
| 18 | |||
| 19 | $modelClass = config('backpack.pagemanager.page_model_class', 'Backpack\PageManager\app\Models\Page'); |
||
| 20 | |||
| 21 | /* |
||
| 22 | |-------------------------------------------------------------------------- |
||
| 23 | | BASIC CRUD INFORMATION |
||
| 24 | |-------------------------------------------------------------------------- |
||
| 25 | */ |
||
| 26 | $this->crud->setModel($modelClass); |
||
| 27 | $this->crud->setRoute(config('backpack.base.route_prefix').'/page'); |
||
| 28 | $this->crud->setEntityNameStrings(trans('backpack::pagemanager.page'), trans('backpack::pagemanager.pages')); |
||
| 29 | |||
| 30 | /* |
||
| 31 | |-------------------------------------------------------------------------- |
||
| 32 | | COLUMNS |
||
| 33 | |-------------------------------------------------------------------------- |
||
| 34 | */ |
||
| 35 | |||
| 36 | $this->crud->addColumn([ |
||
| 37 | 'name' => 'name', |
||
| 38 | 'label' => trans('backpack::pagemanager.name'), |
||
| 39 | ]); |
||
| 40 | $this->crud->addColumn([ |
||
| 41 | 'name' => 'template', |
||
| 42 | 'label' => trans('backpack::pagemanager.template'), |
||
| 43 | 'type' => 'model_function', |
||
| 44 | 'function_name' => 'getTemplateName', |
||
| 45 | ]); |
||
| 46 | $this->crud->addColumn([ |
||
| 47 | 'name' => 'slug', |
||
| 48 | 'label' => trans('backpack::pagemanager.slug'), |
||
| 49 | ]); |
||
| 50 | |||
| 51 | /* |
||
| 52 | |-------------------------------------------------------------------------- |
||
| 53 | | FIELDS |
||
| 54 | |-------------------------------------------------------------------------- |
||
| 55 | */ |
||
| 56 | |||
| 57 | // In PageManager, |
||
| 58 | // - default fields, that all templates are using, are set using $this->addDefaultPageFields(); |
||
| 59 | // - template-specific fields are set per-template, in the PageTemplates trait; |
||
| 60 | |||
| 61 | /* |
||
| 62 | |-------------------------------------------------------------------------- |
||
| 63 | | BUTTONS |
||
| 64 | |-------------------------------------------------------------------------- |
||
| 65 | */ |
||
| 66 | $this->crud->addButtonFromModelFunction('line', 'open', 'getOpenButton', 'beginning'); |
||
| 67 | } |
||
| 68 | |||
| 215 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.