We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
Conditions | 12 |
Paths | 33 |
Total Lines | 33 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 1 | 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 |
||
109 | protected function removeColumnsThatDontBelongInsideShowOperation() |
||
110 | { |
||
111 | // cycle through columns |
||
112 | foreach ($this->crud->columns() as $key => $column) { |
||
113 | |||
114 | // remove any autoset relationship columns |
||
115 | if (array_key_exists('model', $column) && array_key_exists('autoset', $column) && $column['autoset']) { |
||
116 | $this->crud->removeColumn($column['key']); |
||
117 | } |
||
118 | |||
119 | // remove any autoset table columns |
||
120 | if ($column['type'] == 'table' && array_key_exists('autoset', $column) && $column['autoset']) { |
||
121 | $this->crud->removeColumn($column['key']); |
||
122 | } |
||
123 | |||
124 | // remove the row_number column, since it doesn't make sense in this context |
||
125 | if ($column['type'] == 'row_number') { |
||
126 | $this->crud->removeColumn($column['key']); |
||
127 | } |
||
128 | |||
129 | // remove columns that have visibleInShow set as false |
||
130 | if (isset($column['visibleInShow']) && $column['visibleInShow'] == false) { |
||
131 | $this->crud->removeColumn($column['key']); |
||
132 | } |
||
133 | |||
134 | // remove the character limit on columns that take it into account |
||
135 | if (in_array($column['type'], ['text', 'email', 'model_function', 'model_function_attribute', 'phone', 'row_number', 'select'])) { |
||
136 | $this->crud->modifyColumn($column['key'], ['limit' => ($column['limit'] ?? 999)]); |
||
137 | } |
||
138 | } |
||
139 | |||
140 | // remove bulk actions colums |
||
141 | $this->crud->removeColumns(['blank_first_column', 'bulk_actions']); |
||
142 | } |
||
144 |