| Conditions | 15 |
| Paths | 224 |
| Total Lines | 139 |
| Code Lines | 93 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 48 | public function build($globalMode = true) |
||
| 49 | { |
||
| 50 | $plugin = ImsLtiPlugin::create(); |
||
| 51 | $course = $this->tool->getCourse(); |
||
|
|
|||
| 52 | $parent = $this->tool->getParent(); |
||
| 53 | |||
| 54 | $this->addHeader($plugin->get_lang('ToolSettings')); |
||
| 55 | |||
| 56 | if (null !== $course && $globalMode) { |
||
| 57 | $this->addHtml( |
||
| 58 | Display::return_message( |
||
| 59 | sprintf($plugin->get_lang('ToolAddedOnCourseX'), $course->getTitle()), |
||
| 60 | 'normal', |
||
| 61 | false |
||
| 62 | ) |
||
| 63 | ); |
||
| 64 | } |
||
| 65 | |||
| 66 | $this->addText('name', get_lang('Name')); |
||
| 67 | $this->addTextarea('description', get_lang('Description')); |
||
| 68 | $this->addRadio( |
||
| 69 | 'version', |
||
| 70 | $plugin->get_lang('LtiVersion'), |
||
| 71 | [ |
||
| 72 | ImsLti::V_1P1 => 'LTI 1.0 / 1.1', |
||
| 73 | ImsLti::V_1P3 => 'LTI 1.3.0', |
||
| 74 | ] |
||
| 75 | ); |
||
| 76 | $this->freeze(['version']); |
||
| 77 | |||
| 78 | if (null === $parent) { |
||
| 79 | $this->addUrl('launch_url', $plugin->get_lang('LaunchUrl'), true); |
||
| 80 | if ($this->tool->getVersion() === ImsLti::V_1P1) { |
||
| 81 | $this->addText('consumer_key', $plugin->get_lang('ConsumerKey'), false); |
||
| 82 | $this->addText('shared_secret', $plugin->get_lang('SharedSecret'), false); |
||
| 83 | } elseif ($this->tool->getVersion() === ImsLti::V_1P3) { |
||
| 84 | $this->addText('client_id', $plugin->get_lang('ClientId'), true); |
||
| 85 | $this->freeze(['client_id']); |
||
| 86 | $this->addTextarea( |
||
| 87 | 'public_key', |
||
| 88 | $plugin->get_lang('PublicKey'), |
||
| 89 | ['style' => 'font-family: monospace;', 'rows' => 5], |
||
| 90 | true |
||
| 91 | ); |
||
| 92 | $this->addUrl('login_url', $plugin->get_lang('LoginUrl')); |
||
| 93 | $this->addUrl('redirect_url', $plugin->get_lang('RedirectUrl')); |
||
| 94 | } |
||
| 95 | } |
||
| 96 | |||
| 97 | $this->addButtonAdvancedSettings('lti_adv'); |
||
| 98 | $this->addHtml('<div id="lti_adv_options" style="display:none;">'); |
||
| 99 | $this->addTextarea( |
||
| 100 | 'custom_params', |
||
| 101 | [$plugin->get_lang('CustomParams'), $plugin->get_lang('CustomParamsHelp')] |
||
| 102 | ); |
||
| 103 | $this->addSelect( |
||
| 104 | 'document_target', |
||
| 105 | get_lang('LinkTarget'), |
||
| 106 | ['iframe' => 'iframe', 'window' => 'window'] |
||
| 107 | ); |
||
| 108 | |||
| 109 | if (null === $parent |
||
| 110 | || (null !== $parent && !$parent->isActiveDeepLinking()) |
||
| 111 | ) { |
||
| 112 | $this->addCheckBox( |
||
| 113 | 'deep_linking', |
||
| 114 | [null, $plugin->get_lang('SupportDeppLinkingHelp'), null], |
||
| 115 | $plugin->get_lang('SupportDeepLinking') |
||
| 116 | ); |
||
| 117 | } |
||
| 118 | |||
| 119 | if (null === $parent && $this->tool->getVersion() === ImsLti::V_1P3) { |
||
| 120 | $showAGS = false; |
||
| 121 | |||
| 122 | if (api_get_course_int_id()) { |
||
| 123 | $caterories = Category::load(null, null, api_get_course_id()); |
||
| 124 | |||
| 125 | if (!empty($caterories)) { |
||
| 126 | $showAGS = true; |
||
| 127 | } |
||
| 128 | } else { |
||
| 129 | $showAGS = true; |
||
| 130 | } |
||
| 131 | |||
| 132 | if ($showAGS) { |
||
| 133 | $this->addRadio( |
||
| 134 | '1p3_ags', |
||
| 135 | $plugin->get_lang('AssigmentAndGradesService'), |
||
| 136 | [ |
||
| 137 | LtiAssignmentGradesService::AGS_NONE => $plugin->get_lang('DontUseService'), |
||
| 138 | LtiAssignmentGradesService::AGS_SIMPLE => $plugin->get_lang('AGServiceSimple'), |
||
| 139 | LtiAssignmentGradesService::AGS_FULL => $plugin->get_lang('AGServiceFull'), |
||
| 140 | ] |
||
| 141 | ); |
||
| 142 | } else { |
||
| 143 | $gradebookUrl = api_get_path(WEB_CODE_PATH).'gradebook/index.php?'.api_get_cidreq(); |
||
| 144 | |||
| 145 | $this->addLabel( |
||
| 146 | $plugin->get_lang('AssigmentAndGradesService'), |
||
| 147 | sprintf( |
||
| 148 | $plugin->get_lang('YouNeedCreateTheGradebokInCourseFirst'), |
||
| 149 | Display::url($gradebookUrl, $gradebookUrl) |
||
| 150 | ) |
||
| 151 | ); |
||
| 152 | } |
||
| 153 | |||
| 154 | $this->addRadio( |
||
| 155 | '1p3_nrps', |
||
| 156 | $plugin->get_lang('NamesAndRoleProvisioningService'), |
||
| 157 | [ |
||
| 158 | LtiNamesRoleProvisioningService::NRPS_NONE => $plugin->get_lang('DontUseService'), |
||
| 159 | LtiNamesRoleProvisioningService::NRPS_CONTEXT_MEMBERSHIP => $plugin->get_lang('UseService'), |
||
| 160 | ] |
||
| 161 | ); |
||
| 162 | } |
||
| 163 | |||
| 164 | if (!$parent) { |
||
| 165 | $this->addText( |
||
| 166 | 'replacement_user_id', |
||
| 167 | [ |
||
| 168 | $plugin->get_lang('ReplacementUserId'), |
||
| 169 | $plugin->get_lang('ReplacementUserIdHelp'), |
||
| 170 | ], |
||
| 171 | false |
||
| 172 | ); |
||
| 173 | $this->applyFilter('replacement_user_id', 'trim'); |
||
| 174 | } |
||
| 175 | |||
| 176 | $this->addHtml('</div>'); |
||
| 177 | $this->addButtonAdvancedSettings('lti_privacy', get_lang('Privacy')); |
||
| 178 | $this->addHtml('<div id="lti_privacy_options" style="display:none;">'); |
||
| 179 | $this->addCheckBox('share_name', null, $plugin->get_lang('ShareLauncherName')); |
||
| 180 | $this->addCheckBox('share_email', null, $plugin->get_lang('ShareLauncherEmail')); |
||
| 181 | $this->addCheckBox('share_picture', null, $plugin->get_lang('ShareLauncherPicture')); |
||
| 182 | $this->addHtml('</div>'); |
||
| 183 | $this->addButtonUpdate($plugin->get_lang('EditExternalTool')); |
||
| 184 | $this->addHidden('id', $this->tool->getId()); |
||
| 185 | $this->addHidden('action', 'edit'); |
||
| 186 | $this->applyFilter('__ALL__', 'trim'); |
||
| 187 | } |
||
| 221 |
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.