We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Conditions | 10 |
| Paths | 34 |
| Total Lines | 42 |
| Code Lines | 25 |
| 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 |
||
| 39 | public function main($content, $conf) |
||
| 40 | { |
||
| 41 | $this->init($conf); |
||
| 42 | // Merge configuration with conf array of toolbox. |
||
| 43 | if (!empty($this->cObj->data['conf'])) { |
||
| 44 | $this->conf = Helper::mergeRecursiveWithOverrule($this->cObj->data['conf'], $this->conf); |
||
|
|
|||
| 45 | } |
||
| 46 | // Load current document. |
||
| 47 | $this->loadDocument(); |
||
| 48 | if ( |
||
| 49 | $this->doc === null |
||
| 50 | || $this->doc->numPages < 1 |
||
| 51 | || empty($this->conf['fileGrpsImageDownload']) |
||
| 52 | ) { |
||
| 53 | // Quit without doing anything if required variables are not set. |
||
| 54 | return $content; |
||
| 55 | } else { |
||
| 56 | if (!empty($this->piVars['logicalPage'])) { |
||
| 57 | $this->piVars['page'] = $this->doc->getPhysicalPage($this->piVars['logicalPage']); |
||
| 58 | // The logical page parameter should not appear again |
||
| 59 | unset($this->piVars['logicalPage']); |
||
| 60 | } |
||
| 61 | // Set default values if not set. |
||
| 62 | // $this->piVars['page'] may be integer or string (physical structure @ID) |
||
| 63 | if ( |
||
| 64 | (int) $this->piVars['page'] > 0 |
||
| 65 | || empty($this->piVars['page']) |
||
| 66 | ) { |
||
| 67 | $this->piVars['page'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange((int) $this->piVars['page'], 1, $this->doc->numPages, 1); |
||
| 68 | } else { |
||
| 69 | $this->piVars['page'] = array_search($this->piVars['page'], $this->doc->physicalStructure); |
||
| 70 | } |
||
| 71 | $this->piVars['double'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->piVars['double'], 0, 1, 0); |
||
| 72 | } |
||
| 73 | // Load template file. |
||
| 74 | $this->getTemplate(); |
||
| 75 | // Get left or single page download. |
||
| 76 | $markerArray['###IMAGE_LEFT###'] = $this->piVars['double'] == 1 ? $this->getImage($this->piVars['page'], $this->pi_getLL('leftPage', '')) : $this->getImage($this->piVars['page'], $this->pi_getLL('singlePage', '')); |
||
| 77 | // Get right page download. |
||
| 78 | $markerArray['###IMAGE_RIGHT###'] = $this->piVars['double'] == 1 ? $this->getImage($this->piVars['page'] + 1, $this->pi_getLL('rightPage', '')) : ''; |
||
| 79 | $content .= $this->templateService->substituteMarkerArray($this->template, $markerArray); |
||
| 80 | return $this->pi_wrapInBaseClass($content); |
||
| 81 | } |
||
| 129 |