We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
Conditions | 17 |
Paths | 41 |
Total Lines | 82 |
Code Lines | 51 |
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 |
||
175 | public function makeMenuArray() |
||
176 | { |
||
177 | // Load current document. |
||
178 | $this->loadDocument($this->requestData); |
||
179 | if ( |
||
180 | $this->document === null |
||
181 | || $this->document->getDoc() === null |
||
182 | ) { |
||
183 | // Quit without doing anything if required variables are not set. |
||
184 | return []; |
||
185 | } else { |
||
186 | if (!empty($this->requestData['logicalPage'])) { |
||
187 | $this->requestData['page'] = $this->document->getDoc()->getPhysicalPage($this->requestData['logicalPage']); |
||
188 | // The logical page parameter should not appear again |
||
189 | unset($this->requestData['logicalPage']); |
||
190 | } |
||
191 | // Set default values for page if not set. |
||
192 | // $this->piVars['page'] may be integer or string (physical structure @ID) |
||
193 | if ( |
||
194 | (int) $this->requestData['page'] > 0 |
||
195 | || empty($this->requestData['page']) |
||
196 | ) { |
||
197 | $this->requestData['page'] = MathUtility::forceIntegerInRange((int) $this->requestData['page'], |
||
198 | 1, $this->document->getDoc()->numPages, 1); |
||
199 | } else { |
||
200 | $this->requestData['page'] = array_search($this->requestData['page'], $this->document->getDoc()->physicalStructure); |
||
201 | } |
||
202 | $this->requestData['double'] = MathUtility::forceIntegerInRange($this->requestData['double'], |
||
203 | 0, 1, 0); |
||
204 | } |
||
205 | $menuArray = []; |
||
206 | // Does the document have physical elements or is it an external file? |
||
207 | if ( |
||
208 | !empty($this->document->getDoc()->physicalStructure) |
||
209 | || !MathUtility::canBeInterpretedAsInteger($this->requestData['id']) |
||
210 | ) { |
||
211 | // Get all logical units the current page or track is a part of. |
||
212 | if ( |
||
213 | !empty($this->requestData['page']) |
||
214 | && !empty($this->document->getDoc()->physicalStructure) |
||
215 | ) { |
||
216 | $this->activeEntries = array_merge((array) $this->document->getDoc()->smLinks['p2l'][$this->document->getDoc()->physicalStructure[0]], |
||
217 | (array) $this->document->getDoc()->smLinks['p2l'][$this->document->getDoc()->physicalStructure[$this->requestData['page']]]); |
||
218 | if ( |
||
219 | !empty($this->requestData['double']) |
||
220 | && $this->requestData['page'] < $this->document->getDoc()->numPages |
||
221 | ) { |
||
222 | $this->activeEntries = array_merge($this->activeEntries, |
||
223 | (array) $this->document->getDoc()->smLinks['p2l'][$this->document->getDoc()->physicalStructure[$this->requestData['page'] + 1]]); |
||
224 | } |
||
225 | } |
||
226 | // Go through table of contents and create all menu entries. |
||
227 | foreach ($this->document->getDoc()->tableOfContents as $entry) { |
||
228 | $menuArray[] = $this->getMenuEntry($entry, true); |
||
229 | } |
||
230 | } else { |
||
231 | // Go through table of contents and create top-level menu entries. |
||
232 | foreach ($this->document->getDoc()->tableOfContents as $entry) { |
||
233 | $menuArray[] = $this->getMenuEntry($entry, false); |
||
234 | } |
||
235 | // Build table of contents from database. |
||
236 | $result = $this->documentRepository->getTableOfContentsFromDb($this->document->getUid(), $this->document->getPid(), $this->settings); |
||
237 | |||
238 | $allResults = $result->fetchAll(); |
||
|
|||
239 | |||
240 | if (count($allResults) > 0) { |
||
241 | $menuArray[0]['ITEM_STATE'] = 'CURIFSUB'; |
||
242 | $menuArray[0]['_SUB_MENU'] = []; |
||
243 | foreach ($allResults as $resArray) { |
||
244 | $entry = [ |
||
245 | 'label' => !empty($resArray['mets_label']) ? $resArray['mets_label'] : $resArray['title'], |
||
246 | 'type' => $resArray['type'], |
||
247 | 'volume' => $resArray['volume'], |
||
248 | 'orderlabel' => $resArray['mets_orderlabel'], |
||
249 | 'pagination' => '', |
||
250 | 'targetUid' => $resArray['uid'] |
||
251 | ]; |
||
252 | $menuArray[0]['_SUB_MENU'][] = $this->getMenuEntry($entry, false); |
||
253 | } |
||
254 | } |
||
255 | } |
||
256 | return $menuArray; |
||
257 | } |
||
259 |
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.