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