We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Conditions | 10 |
| Paths | 31 |
| Total Lines | 54 |
| Code Lines | 32 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 55 | public function mainAction() |
||
| 56 | { |
||
| 57 | // Load current document. |
||
| 58 | $this->loadDocument($this->requestData); |
||
| 59 | if ( |
||
| 60 | $this->document === null |
||
| 61 | || $this->document->getDoc() === null |
||
| 62 | ) { |
||
| 63 | // Quit without doing anything if required variables are not set. |
||
| 64 | return ''; |
||
|
|
|||
| 65 | } else { |
||
| 66 | // Set default values if not set. |
||
| 67 | if ($this->document->getDoc()->numPages > 0) { |
||
| 68 | if (!empty($this->requestData['logicalPage'])) { |
||
| 69 | $this->requestData['page'] = $this->document->getDoc()->getPhysicalPage($this->requestData['logicalPage']); |
||
| 70 | // The logical page parameter should not appear |
||
| 71 | unset($this->requestData['logicalPage']); |
||
| 72 | } |
||
| 73 | // Set default values if not set. |
||
| 74 | // $this->requestData['page'] may be integer or string (physical structure @ID) |
||
| 75 | if ( |
||
| 76 | (int) $this->requestData['page'] > 0 |
||
| 77 | || empty($this->requestData['page']) |
||
| 78 | ) { |
||
| 79 | $this->requestData['page'] = MathUtility::forceIntegerInRange((int) $this->requestData['page'], 1, $this->document->getDoc()->numPages, 1); |
||
| 80 | } else { |
||
| 81 | $this->requestData['page'] = array_search($this->requestData['page'], $this->document->getDoc()->physicalStructure); |
||
| 82 | } |
||
| 83 | $this->requestData['double'] = MathUtility::forceIntegerInRange($this->requestData['double'], 0, 1, 0); |
||
| 84 | } else { |
||
| 85 | $this->requestData['page'] = 0; |
||
| 86 | $this->requestData['double'] = 0; |
||
| 87 | } |
||
| 88 | } |
||
| 89 | |||
| 90 | // Steps for X pages backward / forward. Double page view uses double steps. |
||
| 91 | $pageSteps = $this->settings['pageStep'] * ($this->requestData['double'] + 1); |
||
| 92 | |||
| 93 | $this->view->assign('pageSteps', $pageSteps); |
||
| 94 | $this->view->assign('numPages', $this->document->getDoc()->numPages); |
||
| 95 | $this->view->assign('viewData', $this->viewData); |
||
| 96 | |||
| 97 | $pageOptions = []; |
||
| 98 | for ($i = 1; $i <= $this->document->getDoc()->numPages; $i++) { |
||
| 99 | $pageOptions[$i] = '[' . $i . ']' . ($this->document->getDoc()->physicalStructureInfo[$this->document->getDoc()->physicalStructure[$i]]['orderlabel'] ? ' - ' . htmlspecialchars($this->document->getDoc()->physicalStructureInfo[$this->document->getDoc()->physicalStructure[$i]]['orderlabel']) : ''); |
||
| 100 | } |
||
| 101 | $this->view->assign('pageOptions', $pageOptions); |
||
| 102 | |||
| 103 | // prepare feature array for fluid |
||
| 104 | $features = []; |
||
| 105 | foreach (explode(',', $this->settings['features']) as $feature) { |
||
| 106 | $features[$feature] = true; |
||
| 107 | } |
||
| 108 | $this->view->assign('features', $features); |
||
| 109 | } |
||
| 111 |