| Conditions | 7 |
| Paths | 7 |
| 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 |
||
| 142 | public function switchEditors(Doku_Event $event, $param) |
||
| 143 | { |
||
| 144 | if ($event->data !== 'plugin_prosemirror_switch_editors') { |
||
| 145 | return; |
||
| 146 | } |
||
| 147 | $event->preventDefault(); |
||
| 148 | $event->stopPropagation(); |
||
| 149 | |||
| 150 | global $INPUT; |
||
| 151 | |||
| 152 | if ($INPUT->bool('getJSON')) { |
||
| 153 | $text = $INPUT->str('data'); |
||
| 154 | $instructions = p_get_instructions($text); |
||
|
1 ignored issue
–
show
|
|||
| 155 | try { |
||
| 156 | $prosemirrorJSON = p_render('prosemirror', $instructions, $info); |
||
|
1 ignored issue
–
show
|
|||
| 157 | } catch (Throwable $e) { |
||
| 158 | $errorMsg = 'Rendering the page\'s syntax for the WYSIWYG editor failed'; |
||
| 159 | |||
| 160 | /** @var \helper_plugin_prosemirror $helper */ |
||
| 161 | $helper = plugin_load('helper', 'prosemirror'); |
||
|
1 ignored issue
–
show
|
|||
| 162 | if ($helper->tryToLogErrorToSentry($e, ['text' => $text])) { |
||
| 163 | $errorMsg .= ' -- The error has been logged to Sentry.'; |
||
| 164 | } |
||
| 165 | |||
| 166 | http_status(500); |
||
|
1 ignored issue
–
show
|
|||
| 167 | header('Content-Type: application/json'); |
||
| 168 | echo json_encode(['error' => $errorMsg]); |
||
| 169 | return; |
||
| 170 | } |
||
| 171 | $responseData = [ |
||
| 172 | 'json' => $prosemirrorJSON, |
||
| 173 | ]; |
||
| 174 | } else { |
||
| 175 | /** @var \helper_plugin_prosemirror $helper */ |
||
| 176 | $helper = plugin_load('helper', 'prosemirror'); |
||
| 177 | $json = $INPUT->str('data'); |
||
| 178 | try { |
||
| 179 | $syntax = $helper->getSyntaxFromProsemirrorData($json); |
||
| 180 | } catch (Throwable $e) { |
||
| 181 | $errorMsg = 'Parsing the data generated by Prosemirror failed with message: "'; |
||
| 182 | $errorMsg .= $e->getMessage(); |
||
| 183 | $errorMsg .= '"'; |
||
| 184 | |||
| 185 | if ($helper->tryToLogErrorToSentry($e, ['json' => $json])) { |
||
| 186 | $errorMsg .= ' -- The error has been logged to Sentry.'; |
||
| 187 | } |
||
| 188 | |||
| 189 | http_status(500); |
||
| 190 | header('Content-Type: application/json'); |
||
| 191 | echo json_encode(['error' => $errorMsg]); |
||
| 192 | return; |
||
| 193 | } |
||
| 194 | $responseData = [ |
||
| 195 | 'text' => $syntax, |
||
| 196 | ]; |
||
| 197 | } |
||
| 198 | |||
| 199 | header('Content-Type: application/json'); |
||
| 200 | echo json_encode($responseData); |
||
| 201 | } |
||
| 203 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths