| Conditions | 11 |
| Paths | 130 |
| Total Lines | 36 |
| Code Lines | 29 |
| 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 |
||
| 37 | public function PreProcess(Request $request, Wizard $wizard) |
||
|
1 ignored issue
–
show
|
|||
| 38 | { |
||
| 39 | $worksheets = []; |
||
| 40 | $sheets = $wizard->data()['googlesheets']; |
||
| 41 | //it's already in the correct form |
||
| 42 | if (is_array($sheets) && isset($sheets[0])) { |
||
| 43 | return; |
||
| 44 | } |
||
| 45 | foreach ($sheets as $key => $worksheet) { |
||
| 46 | $export = Export::find($worksheet['id']); |
||
| 47 | $sheet['worksheet'] = $export->worksheet; |
||
| 48 | $sheet['languages'] = $export->languages; |
||
| 49 | $sheet['exported_at'] = $export->created_at->toDayDateTimeString(); |
||
| 50 | if ($export->elementset) { |
||
| 51 | $id = $export->elementset->id; |
||
| 52 | $sheet['last_edit'] = ElementAttribute::getLatestDateForElementSet($id); |
||
| 53 | $sheet['elementset_id'] = $id; |
||
| 54 | } |
||
| 55 | if ($export->vocabulary) { |
||
| 56 | $id = $export->vocabulary->id; |
||
| 57 | $sheet['last_edit'] = ConceptAttribute::getLatestDateForVocabulary($id); |
||
| 58 | $sheet['vocabulary_id'] = $id; |
||
| 59 | } |
||
| 60 | $sheet['last_edit'] = |
||
| 61 | $sheet['last_edit'] ? $sheet['last_edit']->toDayDateTimeString() : 'Never Edited'; |
||
| 62 | $sheet['id'] = $export->id . '::' . $key; |
||
| 63 | $lastImport = $export->getLatestImport(); |
||
| 64 | $sheet['last_import'] = |
||
| 65 | ($lastImport && $lastImport->imported_at) ? $lastImport->imported_at->toDayDateTimeString() : |
||
| 66 | 'Never Imported'; |
||
| 67 | $sheet['last_import_batch_id'] = ($lastImport && $lastImport->batch_id) ? $lastImport->batch_id : ''; |
||
| 68 | $worksheets[] = $sheet; |
||
| 69 | } |
||
| 70 | $data = $wizard->data(); |
||
| 71 | $data['googlesheets'] = $worksheets; |
||
| 72 | $wizard->data($data); |
||
| 73 | } |
||
| 130 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.