Conditions | 1 |
Paths | 1 |
Total Lines | 73 |
Code Lines | 26 |
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 |
||
12 | public function setup() |
||
13 | { |
||
14 | /* |
||
15 | |-------------------------------------------------------------------------- |
||
16 | | BASIC CRUD INFORMATION |
||
17 | |-------------------------------------------------------------------------- |
||
18 | */ |
||
19 | $this->crud->setModel(config('webfactor.documents.model_class')); |
||
20 | $this->crud->setRoute(config('webfactor.documents.backend.route_prefix').'/'.config('webfactor.documents.backend.route')); |
||
|
|||
21 | $this->crud->setEntityNameStrings(trans('webfactor::documents.entity_name_singular'), |
||
22 | trans('webfactor::documents.entity_name_plural')); |
||
23 | |||
24 | /* |
||
25 | |-------------------------------------------------------------------------- |
||
26 | | BASIC CRUD INFORMATION |
||
27 | |-------------------------------------------------------------------------- |
||
28 | */ |
||
29 | |||
30 | // ------ CRUD FIELDS |
||
31 | |||
32 | $this->crud->addField([ |
||
33 | 'name' => 'type', |
||
34 | 'label' => 'Dokumentenart', |
||
35 | 'type' => 'select_from_array', |
||
36 | 'options' => $this->getTypeOptions(), |
||
37 | 'allows_null' => false, |
||
38 | 'allows_multiple' => false |
||
39 | ]); |
||
40 | |||
41 | $this->crud->addField([ |
||
42 | 'name' => 'title', |
||
43 | 'label' => trans('webfactor::documents.title') |
||
44 | ]); |
||
45 | |||
46 | $this->crud->addField([ |
||
47 | 'name' => 'body', |
||
48 | 'label' => trans('webfactor::documents.body'), |
||
49 | 'type' => $this->bodyFieldType() |
||
50 | ]); |
||
51 | |||
52 | // ------ CRUD COLUMNS |
||
53 | |||
54 | $this->crud->addColumns([ |
||
55 | [ |
||
56 | 'name' => 'type', |
||
57 | 'label' => trans('webfactor::documents.type') |
||
58 | ], |
||
59 | [ |
||
60 | 'name' => 'title', |
||
61 | 'label' => trans('webfactor::documents.title') |
||
62 | ], |
||
63 | [ |
||
64 | 'name' => 'body', |
||
65 | 'label' => trans('webfactor::documents.body') |
||
66 | ] |
||
67 | ]); |
||
68 | |||
69 | // ------ CRUD BUTTONS |
||
70 | |||
71 | // ------ CRUD ACCESS |
||
72 | |||
73 | // ------ CRUD REORDER |
||
74 | |||
75 | // ------ CRUD DETAILS ROW |
||
76 | |||
77 | // ------ REVISIONS |
||
78 | |||
79 | // ------ AJAX TABLE VIEW |
||
80 | |||
81 | // ------ DATATABLE EXPORT BUTTONS |
||
82 | |||
83 | // ------ ADVANCED QUERIES |
||
84 | } |
||
85 | |||
124 |
Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.