| Conditions | 9 |
| Paths | 108 |
| Total Lines | 64 |
| Code Lines | 42 |
| 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 |
||
| 52 | public function getAdditionalFields(array &$taskInfo, $task, SchedulerModuleController $schedulerModule) |
||
| 53 | { |
||
| 54 | $additionalFields = []; |
||
| 55 | |||
| 56 | if ($schedulerModule->CMD == 'add') { |
||
| 57 | $taskInfo['startPage'] = $taskInfo['startPage'] ?: 0; |
||
| 58 | $taskInfo['configuration'] = $taskInfo['configuration'] ?: []; |
||
| 59 | $taskInfo['depth'] = $taskInfo['depth'] ?: 0; |
||
| 60 | } |
||
| 61 | |||
| 62 | if ($schedulerModule->CMD == 'edit') { |
||
| 63 | $taskInfo['startPage'] = $task->startPage; |
||
| 64 | $taskInfo['configuration'] = $task->configuration; |
||
| 65 | $taskInfo['depth'] = $task->depth; |
||
| 66 | } |
||
| 67 | |||
| 68 | // input for startPage |
||
| 69 | $fieldId = 'task_startPage'; |
||
| 70 | $fieldCode = '<input name="tx_scheduler[startPage]" type="text" id="' . $fieldId . '" value="' . $task->startPage . '" class="form-control" />'; |
||
| 71 | $additionalFields[$fieldId] = [ |
||
| 72 | 'code' => $fieldCode, |
||
| 73 | 'label' => 'LLL:EXT:crawler/Resources/Private/Language/Backend.xlf:crawler_im.startPage' |
||
| 74 | ]; |
||
| 75 | |||
| 76 | // input for depth |
||
| 77 | $fieldId = 'task_depth'; |
||
| 78 | $fieldValueArray = [ |
||
| 79 | '0' => $GLOBALS['LANG']->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.depth_0'), |
||
| 80 | '1' => $GLOBALS['LANG']->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.depth_1'), |
||
| 81 | '2' => $GLOBALS['LANG']->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.depth_2'), |
||
| 82 | '3' => $GLOBALS['LANG']->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.depth_3'), |
||
| 83 | '4' => $GLOBALS['LANG']->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.depth_4'), |
||
| 84 | '99' => $GLOBALS['LANG']->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.depth_infi'), |
||
| 85 | ]; |
||
| 86 | $fieldCode = '<select name="tx_scheduler[depth]" id="' . $fieldId . '" class="form-control">'; |
||
| 87 | |||
| 88 | foreach ($fieldValueArray as $key => $label) { |
||
| 89 | $fieldCode .= "\t" . '<option value="' . $key . '"' . (($key == $task->depth) ? ' selected="selected"' : '') . '>' . $label . '</option>'; |
||
| 90 | } |
||
| 91 | |||
| 92 | $fieldCode .= '</select>'; |
||
| 93 | $additionalFields[$fieldId] = [ |
||
| 94 | 'code' => $fieldCode, |
||
| 95 | 'label' => 'LLL:EXT:crawler/Resources/Private/Language/Backend.xlf:crawler_im.depth' |
||
| 96 | ]; |
||
| 97 | |||
| 98 | // combobox for configuration records |
||
| 99 | $recordsArray = $this->getCrawlerConfigurationRecords(); |
||
| 100 | $fieldId = 'task_configuration'; |
||
| 101 | $fieldCode = '<select name="tx_scheduler[configuration][]" multiple="multiple" id="' . $fieldId . '" class="form-control">'; |
||
| 102 | $fieldCode .= "\t" . '<option value=""></option>'; |
||
| 103 | $arraySize = count($recordsArray); |
||
| 104 | for ($i = 0; $i < $arraySize; $i++) { |
||
| 105 | $fieldCode .= "\t" . '<option ' . $this->getSelectedState($task->configuration, $recordsArray[$i]['name']) . 'value="' . $recordsArray[$i]['name'] . '">' . $recordsArray[$i]['name'] . '</option>'; |
||
|
|
|||
| 106 | } |
||
| 107 | $fieldCode .= '</select>'; |
||
| 108 | |||
| 109 | $additionalFields[$fieldId] = [ |
||
| 110 | 'code' => $fieldCode, |
||
| 111 | 'label' => 'LLL:EXT:crawler/Resources/Private/Language/Backend.xlf:crawler_im.conf' |
||
| 112 | ]; |
||
| 113 | |||
| 114 | return $additionalFields; |
||
| 115 | } |
||
| 116 | |||
| 206 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: