| Conditions | 1 |
| Paths | 1 |
| Total Lines | 54 |
| Code Lines | 15 |
| 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 |
||
| 169 | protected function ___deleteAction() |
||
| 170 | { |
||
| 171 | $deleteConfirm = trans('admin.delete_confirm'); |
||
| 172 | $confirm = trans('admin.confirm'); |
||
| 173 | $cancel = trans('admin.cancel'); |
||
| 174 | |||
| 175 | $script = <<<SCRIPT |
||
| 176 | |||
| 177 | $('.grid-row-delete').unbind('click').click(function() { |
||
| 178 | |||
| 179 | var id = $(this).data('id'); |
||
| 180 | |||
| 181 | swal({ |
||
| 182 | title: "$deleteConfirm", |
||
| 183 | type: "warning", |
||
| 184 | showCancelButton: true, |
||
| 185 | confirmButtonColor: "#DD6B55", |
||
| 186 | confirmButtonText: "$confirm", |
||
| 187 | closeOnConfirm: false, |
||
| 188 | cancelButtonText: "$cancel" |
||
| 189 | }, |
||
| 190 | function(){ |
||
| 191 | $.ajax({ |
||
| 192 | method: 'post', |
||
| 193 | url: '{$this->getResource()}/' + id, |
||
| 194 | data: { |
||
| 195 | _method:'delete', |
||
| 196 | _token:LA.token, |
||
| 197 | }, |
||
| 198 | success: function (data) { |
||
| 199 | $.pjax.reload('#pjax-container'); |
||
| 200 | |||
| 201 | if (typeof data === 'object') { |
||
| 202 | if (data.status) { |
||
| 203 | swal(data.message, '', 'success'); |
||
| 204 | } else { |
||
| 205 | swal(data.message, '', 'error'); |
||
| 206 | } |
||
| 207 | } |
||
| 208 | } |
||
| 209 | }); |
||
| 210 | }); |
||
| 211 | }); |
||
| 212 | |||
| 213 | SCRIPT; |
||
| 214 | |||
| 215 | Admin::script($script); |
||
| 216 | |||
| 217 | return <<<EOT |
||
| 218 | <a href="javascript:void(0);" data-id="{$this->getKey()}" class="grid-row-delete"> |
||
| 219 | <i class="fa fa-trash"></i> |
||
| 220 | </a> |
||
| 221 | EOT; |
||
| 222 | } |
||
| 223 | |||
| 247 |
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.