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