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