| Conditions | 4 |
| Paths | 6 |
| Total Lines | 56 |
| Code Lines | 33 |
| 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 |
||
| 86 | public static function getLpAcquisition( |
||
| 87 | array $lpInfo, |
||
| 88 | int $studentId, |
||
| 89 | int $courseId, |
||
| 90 | int $sessionId = 0, |
||
| 91 | bool $allowEdit = false |
||
| 92 | ): string { |
||
| 93 | $lpView = learnpath::findLastView($lpInfo['iid'], $studentId, $courseId, $sessionId, true); |
||
| 94 | |||
| 95 | $extraField = new ExtraField('lp_view'); |
||
| 96 | $field = $extraField->get_handler_field_info_by_field_variable(self::VARIABLE_ACQUISITION); |
||
| 97 | |||
| 98 | $extraFieldValue = new ExtraFieldValue('lp_view'); |
||
| 99 | $value = $extraFieldValue->get_values_by_handler_and_field_variable($lpView['iid'], self::VARIABLE_ACQUISITION); |
||
| 100 | |||
| 101 | $return = ''; |
||
| 102 | |||
| 103 | if (empty($value)) { |
||
| 104 | $return .= '-'; |
||
| 105 | } else { |
||
| 106 | $optionSelected = array_filter( |
||
| 107 | $field['options'], |
||
| 108 | function (array $option) use ($value) { |
||
| 109 | return $option['option_value'] == $value['value']; |
||
| 110 | } |
||
| 111 | ); |
||
| 112 | |||
| 113 | if (empty($optionSelected)) { |
||
| 114 | $return .= '-'; |
||
| 115 | } else { |
||
| 116 | $optionSelected = current($optionSelected); |
||
| 117 | $valueComment = json_decode($value['comment'], true); |
||
| 118 | |||
| 119 | $register = api_get_user_entity($valueComment['user']); |
||
| 120 | |||
| 121 | $return .= ExtraFieldOption::translateDisplayName($optionSelected['display_text']).'<br>' |
||
| 122 | .Display::tag('small', $register->getCompleteName()).'<br>' |
||
| 123 | .Display::tag( |
||
| 124 | 'small', |
||
| 125 | api_convert_and_format_date($valueComment['datetime'], DATE_TIME_FORMAT_LONG) |
||
| 126 | ).'<br>'; |
||
| 127 | } |
||
| 128 | } |
||
| 129 | |||
| 130 | $editUrl = api_get_path(WEB_AJAX_PATH).'student_follow_page.ajax.php?' |
||
| 131 | .http_build_query(['lp_view' => $lpView['iid'], 'a' => 'form_adquisition']); |
||
| 132 | |||
| 133 | if ($allowEdit) { |
||
| 134 | $return .= Display::url( |
||
| 135 | Display::return_icon('edit.png', get_lang('Edit'), [], ICON_SIZE_TINY), |
||
| 136 | $editUrl, |
||
| 137 | ['class' => 'ajax', 'data-title' => strip_tags($lpInfo['lp_name'])] |
||
| 138 | ); |
||
| 139 | } |
||
| 140 | |||
| 141 | return '<div id="acquisition-'.$lpView['iid'].'">'.$return.'</div>'; |
||
| 142 | } |
||
| 215 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.