Conditions | 1 |
Paths | 1 |
Total Lines | 55 |
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 |
||
177 | protected function deleteAction() |
||
178 | { |
||
179 | $deleteConfirm = trans('admin.delete_confirm'); |
||
180 | $confirm = trans('admin.confirm'); |
||
181 | $cancel = trans('admin.cancel'); |
||
182 | |||
183 | $script = <<<SCRIPT |
||
184 | |||
185 | $('.grid-row-delete').unbind('click').click(function() { |
||
186 | |||
187 | var id = $(this).data('id'); |
||
188 | |||
189 | swal({ |
||
190 | title: "$deleteConfirm", |
||
191 | type: "warning", |
||
192 | showCancelButton: true, |
||
193 | confirmButtonColor: "#DD6B55", |
||
194 | confirmButtonText: "$confirm", |
||
195 | closeOnConfirm: false, |
||
196 | cancelButtonText: "$cancel" |
||
197 | }, |
||
198 | function(){ |
||
199 | $.ajax({ |
||
200 | method: 'post', |
||
201 | url: '{$this->getResourceURL()}/' + id, |
||
202 | data: { |
||
203 | _method:'delete', |
||
204 | _token:LA.token, |
||
205 | }, |
||
206 | success: function (data) { |
||
207 | $.pjax.reload('#pjax-container'); |
||
208 | |||
209 | if (typeof data === 'object') { |
||
210 | if (data.status) { |
||
211 | swal(data.message, '', 'success'); |
||
212 | } else { |
||
213 | swal(data.message, '', 'error'); |
||
214 | } |
||
215 | } |
||
216 | } |
||
217 | }); |
||
218 | }); |
||
219 | }); |
||
220 | |||
221 | SCRIPT; |
||
222 | |||
223 | Admin::script($script); |
||
224 | |||
225 | $deleteText = trans("admin.delete"); |
||
226 | return <<<EOT |
||
227 | <a href="javascript:void(0);" data-id="{$this->getKey()}" class="grid-row-delete"> |
||
228 | <i class="fa fa-trash btn btn-danger" title="{$deleteText}"></i> |
||
229 | </a> |
||
230 | EOT; |
||
231 | } |
||
232 | } |
||
233 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.