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 |
||
| 196 | public function makeMenuArray($requestData) |
||
| 197 | { |
||
| 198 | // Load current document. |
||
| 199 | $this->loadDocument($requestData); |
||
| 200 | if ($this->doc === null) { |
||
| 201 | // Quit without doing anything if required variables are not set. |
||
| 202 | return []; |
||
| 203 | } else { |
||
| 204 | if (!empty($requestData['logicalPage'])) { |
||
| 205 | $requestData['page'] = $this->doc->getPhysicalPage($requestData['logicalPage']); |
||
| 206 | // The logical page parameter should not appear again |
||
| 207 | unset($requestData['logicalPage']); |
||
| 208 | } |
||
| 209 | // Set default values for page if not set. |
||
| 210 | // $this->piVars['page'] may be integer or string (physical structure @ID) |
||
| 211 | if ( |
||
| 212 | (int)$requestData['page'] > 0 |
||
| 213 | || empty($requestData['page']) |
||
| 214 | ) { |
||
| 215 | $requestData['page'] = MathUtility::forceIntegerInRange((int)$requestData['page'], |
||
| 216 | 1, $this->doc->numPages, 1); |
||
| 217 | } else { |
||
| 218 | $requestData['page'] = array_search($requestData['page'], $this->doc->physicalStructure); |
||
| 219 | } |
||
| 220 | $requestData['double'] = MathUtility::forceIntegerInRange($requestData['double'], |
||
| 221 | 0, 1, 0); |
||
| 222 | } |
||
| 223 | $menuArray = []; |
||
| 224 | // Does the document have physical elements or is it an external file? |
||
| 225 | if ( |
||
| 226 | !empty($this->doc->physicalStructure) |
||
| 227 | || !MathUtility::canBeInterpretedAsInteger($this->doc->uid) |
||
| 228 | ) { |
||
| 229 | // Get all logical units the current page or track is a part of. |
||
| 230 | if ( |
||
| 231 | !empty($requestData['page']) |
||
| 232 | && !empty($this->doc->physicalStructure) |
||
| 233 | ) { |
||
| 234 | $this->activeEntries = array_merge((array)$this->doc->smLinks['p2l'][$this->doc->physicalStructure[0]], |
||
| 235 | (array)$this->doc->smLinks['p2l'][$this->doc->physicalStructure[$requestData['page']]]); |
||
| 236 | if ( |
||
| 237 | !empty($requestData['double']) |
||
| 238 | && $requestData['page'] < $this->doc->numPages |
||
| 239 | ) { |
||
| 240 | $this->activeEntries = array_merge($this->activeEntries, |
||
| 241 | (array)$this->doc->smLinks['p2l'][$this->doc->physicalStructure[$requestData['page'] + 1]]); |
||
| 242 | } |
||
| 243 | } |
||
| 244 | // Go through table of contents and create all menu entries. |
||
| 245 | foreach ($this->doc->tableOfContents as $entry) { |
||
| 246 | $menuArray[] = $this->getMenuEntry($entry, true); |
||
| 247 | } |
||
| 248 | } else { |
||
| 249 | // Go through table of contents and create top-level menu entries. |
||
| 250 | foreach ($this->doc->tableOfContents as $entry) { |
||
| 251 | $menuArray[] = $this->getMenuEntry($entry, false); |
||
| 252 | } |
||
| 253 | // Build table of contents from database. |
||
| 254 | $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) |
||
| 255 | ->getQueryBuilderForTable('tx_dlf_documents'); |
||
| 256 | |||
| 257 | $excludeOtherWhere = ''; |
||
| 258 | if ($this->settings['excludeOther']) { |
||
| 259 | $excludeOtherWhere = 'tx_dlf_documents.pid=' . intval($this->settings['pages']); |
||
| 260 | } |
||
| 261 | // Check if there are any metadata to suggest. |
||
| 262 | $result = $queryBuilder |
||
| 263 | ->select( |
||
| 264 | 'tx_dlf_documents.uid AS uid', |
||
| 265 | 'tx_dlf_documents.title AS title', |
||
| 266 | 'tx_dlf_documents.volume AS volume', |
||
| 267 | 'tx_dlf_documents.mets_label AS mets_label', |
||
| 268 | 'tx_dlf_documents.mets_orderlabel AS mets_orderlabel', |
||
| 269 | 'tx_dlf_structures_join.index_name AS type' |
||
| 270 | ) |
||
| 271 | ->innerJoin( |
||
| 272 | 'tx_dlf_documents', |
||
| 273 | 'tx_dlf_structures', |
||
| 274 | 'tx_dlf_structures_join', |
||
| 275 | $queryBuilder->expr()->eq( |
||
| 276 | 'tx_dlf_structures_join.uid', |
||
| 277 | 'tx_dlf_documents.structure' |
||
| 278 | ) |
||
| 279 | ) |
||
| 280 | ->from('tx_dlf_documents') |
||
| 281 | ->where( |
||
| 282 | $queryBuilder->expr()->eq('tx_dlf_documents.partof', intval($this->doc->uid)), |
||
| 283 | $queryBuilder->expr()->eq('tx_dlf_structures_join.pid', intval($this->doc->pid)), |
||
| 284 | $excludeOtherWhere |
||
| 285 | ) |
||
| 286 | ->addOrderBy('tx_dlf_documents.volume_sorting') |
||
| 287 | ->addOrderBy('tx_dlf_documents.mets_orderlabel') |
||
| 288 | ->execute(); |
||
| 289 | |||
| 290 | $allResults = $result->fetchAll(); |
||
| 291 | |||
| 292 | if (count($allResults) > 0) { |
||
| 293 | $menuArray[0]['ITEM_STATE'] = 'CURIFSUB'; |
||
| 294 | $menuArray[0]['_SUB_MENU'] = []; |
||
| 295 | foreach ($allResults as $resArray) { |
||
| 296 | $entry = [ |
||
| 297 | 'label' => !empty($resArray['mets_label']) ? $resArray['mets_label'] : $resArray['title'], |
||
| 298 | 'type' => $resArray['type'], |
||
| 299 | 'volume' => $resArray['volume'], |
||
| 300 | 'orderlabel' => $resArray['mets_orderlabel'], |
||
| 301 | 'pagination' => '', |
||
| 302 | 'targetUid' => $resArray['uid'] |
||
| 303 | ]; |
||
| 304 | $menuArray[0]['_SUB_MENU'][] = $this->getMenuEntry($entry, false); |
||
| 305 | } |
||
| 306 | } |
||
| 307 | } |
||
| 308 | return $menuArray; |
||
| 309 | } |
||
| 368 |
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