We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Conditions | 17 |
| Paths | 57 |
| Total Lines | 113 |
| Code Lines | 76 |
| 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 |
||
| 172 | public function makeMenuArray($requestData) |
||
| 173 | { |
||
| 174 | // Load current document. |
||
| 175 | $this->loadDocument($requestData); |
||
| 176 | if ($this->doc === null) { |
||
| 177 | // Quit without doing anything if required variables are not set. |
||
| 178 | return []; |
||
| 179 | } else { |
||
| 180 | if (!empty($requestData['logicalPage'])) { |
||
| 181 | $requestData['page'] = $this->doc->getPhysicalPage($requestData['logicalPage']); |
||
| 182 | // The logical page parameter should not appear again |
||
| 183 | unset($requestData['logicalPage']); |
||
| 184 | } |
||
| 185 | // Set default values for page if not set. |
||
| 186 | // $this->piVars['page'] may be integer or string (physical structure @ID) |
||
| 187 | if ( |
||
| 188 | (int) $requestData['page'] > 0 |
||
| 189 | || empty($requestData['page']) |
||
| 190 | ) { |
||
| 191 | $requestData['page'] = MathUtility::forceIntegerInRange((int) $requestData['page'], |
||
| 192 | 1, $this->doc->numPages, 1); |
||
| 193 | } else { |
||
| 194 | $requestData['page'] = array_search($requestData['page'], $this->doc->physicalStructure); |
||
| 195 | } |
||
| 196 | $requestData['double'] = MathUtility::forceIntegerInRange($requestData['double'], |
||
| 197 | 0, 1, 0); |
||
| 198 | } |
||
| 199 | $menuArray = []; |
||
| 200 | // Does the document have physical elements or is it an external file? |
||
| 201 | if ( |
||
| 202 | !empty($this->doc->physicalStructure) |
||
| 203 | || !MathUtility::canBeInterpretedAsInteger($this->doc->uid) |
||
| 204 | ) { |
||
| 205 | // Get all logical units the current page or track is a part of. |
||
| 206 | if ( |
||
| 207 | !empty($requestData['page']) |
||
| 208 | && !empty($this->doc->physicalStructure) |
||
| 209 | ) { |
||
| 210 | $this->activeEntries = array_merge((array) $this->doc->smLinks['p2l'][$this->doc->physicalStructure[0]], |
||
| 211 | (array) $this->doc->smLinks['p2l'][$this->doc->physicalStructure[$requestData['page']]]); |
||
| 212 | if ( |
||
| 213 | !empty($requestData['double']) |
||
| 214 | && $requestData['page'] < $this->doc->numPages |
||
| 215 | ) { |
||
| 216 | $this->activeEntries = array_merge($this->activeEntries, |
||
| 217 | (array) $this->doc->smLinks['p2l'][$this->doc->physicalStructure[$requestData['page'] + 1]]); |
||
| 218 | } |
||
| 219 | } |
||
| 220 | // Go through table of contents and create all menu entries. |
||
| 221 | foreach ($this->doc->tableOfContents as $entry) { |
||
| 222 | $menuArray[] = $this->getMenuEntry($entry, true); |
||
| 223 | } |
||
| 224 | } else { |
||
| 225 | // Go through table of contents and create top-level menu entries. |
||
| 226 | foreach ($this->doc->tableOfContents as $entry) { |
||
| 227 | $menuArray[] = $this->getMenuEntry($entry, false); |
||
| 228 | } |
||
| 229 | // Build table of contents from database. |
||
| 230 | $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) |
||
| 231 | ->getQueryBuilderForTable('tx_dlf_documents'); |
||
| 232 | |||
| 233 | $excludeOtherWhere = ''; |
||
| 234 | if ($this->settings['excludeOther']) { |
||
| 235 | $excludeOtherWhere = 'tx_dlf_documents.pid=' . intval($this->settings['pages']); |
||
| 236 | } |
||
| 237 | // Check if there are any metadata to suggest. |
||
| 238 | $result = $queryBuilder |
||
| 239 | ->select( |
||
| 240 | 'tx_dlf_documents.uid AS uid', |
||
| 241 | 'tx_dlf_documents.title AS title', |
||
| 242 | 'tx_dlf_documents.volume AS volume', |
||
| 243 | 'tx_dlf_documents.mets_label AS mets_label', |
||
| 244 | 'tx_dlf_documents.mets_orderlabel AS mets_orderlabel', |
||
| 245 | 'tx_dlf_structures_join.index_name AS type' |
||
| 246 | ) |
||
| 247 | ->innerJoin( |
||
| 248 | 'tx_dlf_documents', |
||
| 249 | 'tx_dlf_structures', |
||
| 250 | 'tx_dlf_structures_join', |
||
| 251 | $queryBuilder->expr()->eq( |
||
| 252 | 'tx_dlf_structures_join.uid', |
||
| 253 | 'tx_dlf_documents.structure' |
||
| 254 | ) |
||
| 255 | ) |
||
| 256 | ->from('tx_dlf_documents') |
||
| 257 | ->where( |
||
| 258 | $queryBuilder->expr()->eq('tx_dlf_documents.partof', intval($this->doc->uid)), |
||
| 259 | $queryBuilder->expr()->eq('tx_dlf_structures_join.pid', intval($this->doc->pid)), |
||
| 260 | $excludeOtherWhere |
||
| 261 | ) |
||
| 262 | ->addOrderBy('tx_dlf_documents.volume_sorting') |
||
| 263 | ->addOrderBy('tx_dlf_documents.mets_orderlabel') |
||
| 264 | ->execute(); |
||
| 265 | |||
| 266 | $allResults = $result->fetchAll(); |
||
| 267 | |||
| 268 | if (count($allResults) > 0) { |
||
| 269 | $menuArray[0]['ITEM_STATE'] = 'CURIFSUB'; |
||
| 270 | $menuArray[0]['_SUB_MENU'] = []; |
||
| 271 | foreach ($allResults as $resArray) { |
||
| 272 | $entry = [ |
||
| 273 | 'label' => !empty($resArray['mets_label']) ? $resArray['mets_label'] : $resArray['title'], |
||
| 274 | 'type' => $resArray['type'], |
||
| 275 | 'volume' => $resArray['volume'], |
||
| 276 | 'orderlabel' => $resArray['mets_orderlabel'], |
||
| 277 | 'pagination' => '', |
||
| 278 | 'targetUid' => $resArray['uid'] |
||
| 279 | ]; |
||
| 280 | $menuArray[0]['_SUB_MENU'][] = $this->getMenuEntry($entry, false); |
||
| 281 | } |
||
| 282 | } |
||
| 283 | } |
||
| 284 | return $menuArray; |
||
| 285 | } |
||
| 287 |
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.