We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Conditions | 11 |
| Paths | 33 |
| Total Lines | 61 |
| Code Lines | 38 |
| 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 |
||
| 25 | public function mainAction() |
||
| 26 | { |
||
| 27 | $requestData = GeneralUtility::_GPmerged('tx_dlf'); |
||
| 28 | unset($requestData['__referrer'], $requestData['__trustedProperties']); |
||
| 29 | |||
| 30 | if (empty($requestData['id'])) { |
||
| 31 | return ''; |
||
|
|
|||
| 32 | } |
||
| 33 | if (empty($requestData['page'])) { |
||
| 34 | $requestData['page'] = 1; |
||
| 35 | } |
||
| 36 | // Load current document. |
||
| 37 | $this->loadDocument($requestData); |
||
| 38 | if ($this->doc === null) { |
||
| 39 | // Quit without doing anything if required variables are not set. |
||
| 40 | return; |
||
| 41 | } else { |
||
| 42 | // Set default values if not set. |
||
| 43 | if ($this->doc->numPages > 0) { |
||
| 44 | if (!empty($requestData['logicalPage'])) { |
||
| 45 | $requestData['page'] = $this->doc->getPhysicalPage($requestData['logicalPage']); |
||
| 46 | // The logical page parameter should not appear |
||
| 47 | unset($requestData['logicalPage']); |
||
| 48 | } |
||
| 49 | // Set default values if not set. |
||
| 50 | // $requestData['page'] may be integer or string (physical structure @ID) |
||
| 51 | if ( |
||
| 52 | (int) $requestData['page'] > 0 |
||
| 53 | || empty($requestData['page']) |
||
| 54 | ) { |
||
| 55 | $requestData['page'] = MathUtility::forceIntegerInRange((int) $requestData['page'], 1, $this->doc->numPages, 1); |
||
| 56 | } else { |
||
| 57 | $requestData['page'] = array_search($requestData['page'], $this->doc->physicalStructure); |
||
| 58 | } |
||
| 59 | $requestData['double'] = MathUtility::forceIntegerInRange($requestData['double'], 0, 1, 0); |
||
| 60 | } else { |
||
| 61 | $requestData['page'] = 0; |
||
| 62 | $requestData['double'] = 0; |
||
| 63 | } |
||
| 64 | } |
||
| 65 | |||
| 66 | // Steps for X pages backward / forward. Double page view uses double steps. |
||
| 67 | $pageSteps = $this->settings['pageStep'] * ($requestData['double'] + 1); |
||
| 68 | |||
| 69 | $this->view->assign('page', $requestData['page']); |
||
| 70 | $this->view->assign('docId', $this->doc->uid); |
||
| 71 | $this->view->assign('pageId', $GLOBALS['TSFE']->id); |
||
| 72 | $this->view->assign('pageSteps', $pageSteps); |
||
| 73 | $this->view->assign('double', $requestData['double']); |
||
| 74 | $this->view->assign('numPages', $this->doc->numPages); |
||
| 75 | |||
| 76 | // TODO: Check if f:link.action can be used in template Navigation->main |
||
| 77 | $this->view->assign('pageToList', $this->settings['targetPid']); |
||
| 78 | $this->view->assign('forceAbsoluteUrl', !empty($this->conf['settings.forceAbsoluteUrl']) ? 1 : 0); |
||
| 79 | |||
| 80 | $pageOptions = []; |
||
| 81 | for ($i = 1; $i <= $this->doc->numPages; $i++) { |
||
| 82 | $pageOptions[$i] = ($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$i]]['orderlabel'] ? ' - ' . htmlspecialchars($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$i]]['orderlabel']) : ''); |
||
| 83 | } |
||
| 84 | $this->view->assign('uniqueId', uniqid(Helper::getUnqualifiedClassName(get_class($this)) . '-')); |
||
| 85 | $this->view->assign('pageOptions', $pageOptions); |
||
| 86 | |||
| 89 |