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 |
||
111 | protected function removeColumnsThatDontBelongInsideShowOperation() |
||
112 | { |
||
113 | // cycle through columns |
||
114 | foreach ($this->crud->columns() as $key => $column) { |
||
115 | |||
116 | // remove any autoset relationship columns |
||
117 | if (array_key_exists('model', $column) && array_key_exists('autoset', $column) && $column['autoset']) { |
||
118 | $this->crud->removeColumn($column['key']); |
||
119 | } |
||
120 | |||
121 | // remove any autoset table columns |
||
122 | if ($column['type'] == 'table' && array_key_exists('autoset', $column) && $column['autoset']) { |
||
123 | $this->crud->removeColumn($column['key']); |
||
124 | } |
||
125 | |||
126 | // remove the row_number column, since it doesn't make sense in this context |
||
127 | if ($column['type'] == 'row_number') { |
||
128 | $this->crud->removeColumn($column['key']); |
||
129 | } |
||
130 | |||
131 | // remove columns that have visibleInShow set as false |
||
132 | if (isset($column['visibleInShow']) && $column['visibleInShow'] == false) { |
||
133 | $this->crud->removeColumn($column['key']); |
||
134 | } |
||
135 | |||
136 | // remove the character limit on columns that take it into account |
||
137 | if (in_array($column['type'], ['text', 'email', 'model_function', 'model_function_attribute', 'phone', 'row_number', 'select'])) { |
||
138 | $this->crud->modifyColumn($column['key'], ['limit' => ($column['limit'] ?? 999)]); |
||
139 | } |
||
140 | } |
||
141 | |||
142 | // remove bulk actions colums |
||
143 | $this->crud->removeColumns(['blank_first_column', 'bulk_actions']); |
||
144 | } |
||
146 |