We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Conditions | 14 |
| Paths | 20 |
| Total Lines | 65 |
| Code Lines | 41 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| 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 |
||
| 69 | protected function makeMenuArray() |
||
| 70 | { |
||
| 71 | // Set default values for page if not set. |
||
| 72 | // $this->requestData['page'] may be integer or string (physical structure @ID) |
||
| 73 | if ( |
||
| 74 | (int) $this->requestData['page'] > 0 |
||
| 75 | || empty($this->requestData['page']) |
||
| 76 | ) { |
||
| 77 | $this->requestData['page'] = MathUtility::forceIntegerInRange((int) $this->requestData['page'], 1, $this->document->getDoc()->numPages, 1); |
||
| 78 | } else { |
||
| 79 | $this->requestData['page'] = array_search($this->requestData['page'], $this->document->getDoc()->physicalStructure); |
||
| 80 | } |
||
| 81 | $this->requestData['double'] = MathUtility::forceIntegerInRange($this->requestData['double'], 0, 1, 0); |
||
| 82 | $menuArray = []; |
||
| 83 | // Does the document have physical elements or is it an external file? |
||
| 84 | if ( |
||
| 85 | !empty($this->document->getDoc()->physicalStructure) |
||
| 86 | || !MathUtility::canBeInterpretedAsInteger($this->requestData['id']) |
||
| 87 | ) { |
||
| 88 | // Get all logical units the current page or track is a part of. |
||
| 89 | if ( |
||
| 90 | !empty($this->requestData['page']) |
||
| 91 | && !empty($this->document->getDoc()->physicalStructure) |
||
| 92 | ) { |
||
| 93 | $this->activeEntries = array_merge((array) $this->document->getDoc()->smLinks['p2l'][$this->document->getDoc()->physicalStructure[0]], |
||
| 94 | (array) $this->document->getDoc()->smLinks['p2l'][$this->document->getDoc()->physicalStructure[$this->requestData['page']]]); |
||
| 95 | if ( |
||
| 96 | !empty($this->requestData['double']) |
||
| 97 | && $this->requestData['page'] < $this->document->getDoc()->numPages |
||
| 98 | ) { |
||
| 99 | $this->activeEntries = array_merge($this->activeEntries, |
||
| 100 | (array) $this->document->getDoc()->smLinks['p2l'][$this->document->getDoc()->physicalStructure[$this->requestData['page'] + 1]]); |
||
| 101 | } |
||
| 102 | } |
||
| 103 | // Go through table of contents and create all menu entries. |
||
| 104 | foreach ($this->document->getDoc()->tableOfContents as $entry) { |
||
| 105 | $menuArray[] = $this->getMenuEntry($entry, true); |
||
| 106 | } |
||
| 107 | } else { |
||
| 108 | // Go through table of contents and create top-level menu entries. |
||
| 109 | foreach ($this->document->getDoc()->tableOfContents as $entry) { |
||
| 110 | $menuArray[] = $this->getMenuEntry($entry, false); |
||
| 111 | } |
||
| 112 | // Build table of contents from database. |
||
| 113 | $result = $this->documentRepository->getTableOfContentsFromDb($this->document->getUid(), $this->document->getPid(), $this->settings); |
||
| 114 | |||
| 115 | $allResults = $result->fetchAll(); |
||
|
|
|||
| 116 | |||
| 117 | if (count($allResults) > 0) { |
||
| 118 | $menuArray[0]['ITEM_STATE'] = 'CURIFSUB'; |
||
| 119 | $menuArray[0]['_SUB_MENU'] = []; |
||
| 120 | foreach ($allResults as $resArray) { |
||
| 121 | $entry = [ |
||
| 122 | 'label' => !empty($resArray['mets_label']) ? $resArray['mets_label'] : $resArray['title'], |
||
| 123 | 'type' => $resArray['type'], |
||
| 124 | 'volume' => $resArray['volume'], |
||
| 125 | 'orderlabel' => $resArray['mets_orderlabel'], |
||
| 126 | 'pagination' => '', |
||
| 127 | 'targetUid' => $resArray['uid'] |
||
| 128 | ]; |
||
| 129 | $menuArray[0]['_SUB_MENU'][] = $this->getMenuEntry($entry, false); |
||
| 130 | } |
||
| 131 | } |
||
| 132 | } |
||
| 133 | return $menuArray; |
||
| 134 | } |
||
| 258 |
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.