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 |
||
183 | protected function renderDelete() |
||
184 | { |
||
185 | $deleteConfirm = trans('admin.delete_confirm'); |
||
186 | $confirm = trans('admin.confirm'); |
||
187 | $cancel = trans('admin.cancel'); |
||
188 | |||
189 | $script = <<<SCRIPT |
||
190 | |||
191 | $('.{$this->grid->getGridRowName()}-delete').unbind('click').click(function() { |
||
192 | |||
193 | var id = $(this).data('id'); |
||
194 | |||
195 | swal({ |
||
196 | title: "$deleteConfirm", |
||
197 | type: "warning", |
||
198 | showCancelButton: true, |
||
199 | confirmButtonColor: "#DD6B55", |
||
200 | confirmButtonText: "$confirm", |
||
201 | closeOnConfirm: false, |
||
202 | cancelButtonText: "$cancel" |
||
203 | }, |
||
204 | function(){ |
||
205 | $.ajax({ |
||
206 | method: 'post', |
||
207 | url: '{$this->getResourceURL()}/' + id, |
||
208 | data: { |
||
209 | _method:'delete', |
||
210 | _token:LA.token, |
||
211 | }, |
||
212 | success: function (data) { |
||
213 | $.pjax.reload('#pjax-container'); |
||
214 | |||
215 | if (typeof data === 'object') { |
||
216 | if (data.status) { |
||
217 | swal(data.message, '', 'success'); |
||
218 | } else { |
||
219 | swal(data.message, '', 'error'); |
||
220 | } |
||
221 | } |
||
222 | } |
||
223 | }); |
||
224 | }); |
||
225 | }); |
||
226 | |||
227 | SCRIPT; |
||
228 | |||
229 | Admin::script($script); |
||
230 | |||
231 | $deleteText = trans("admin.delete"); |
||
232 | return <<<EOT |
||
233 | <a href="javascript:void(0);" data-id="{$this->getKey()}" class="{$this->grid->getGridRowName()}-delete"> |
||
234 | <i class="fa fa-trash btn btn-danger" title="{$deleteText}"></i> |
||
235 | </a> |
||
236 | EOT; |
||
237 | } |
||
238 | } |
||
239 |
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.