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