We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Conditions | 12 |
| Paths | 42 |
| Total Lines | 74 |
| Code Lines | 44 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 5 | ||
| Bugs | 1 | 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 |
||
| 41 | public function main($content, $conf) |
||
| 42 | { |
||
| 43 | |||
| 44 | $this->init($conf); |
||
| 45 | |||
| 46 | // Merge configuration with conf array of toolbox. |
||
| 47 | if (!empty($this->cObj->data['conf'])) { |
||
| 48 | $this->conf = Helper::mergeRecursiveWithOverrule($this->cObj->data['conf'], $this->conf); |
||
|
|
|||
| 49 | } |
||
| 50 | |||
| 51 | $this->addSearchInDocumentJS(); |
||
| 52 | |||
| 53 | // Load current document. |
||
| 54 | $this->loadDocument(); |
||
| 55 | if ( |
||
| 56 | $this->doc === null |
||
| 57 | || $this->doc->numPages < 1 |
||
| 58 | || empty($this->conf['fileGrpFulltext']) |
||
| 59 | || empty($this->conf['solrcore']) |
||
| 60 | ) { |
||
| 61 | // Quit without doing anything if required variables are not set. |
||
| 62 | return $content; |
||
| 63 | } else { |
||
| 64 | if (!empty($this->piVars['logicalPage'])) { |
||
| 65 | $this->piVars['page'] = $this->doc->getPhysicalPage($this->piVars['logicalPage']); |
||
| 66 | // The logical page parameter should not appear again |
||
| 67 | unset($this->piVars['logicalPage']); |
||
| 68 | } |
||
| 69 | // Set default values if not set. |
||
| 70 | // $this->piVars['page'] may be integer or string (physical structure @ID) |
||
| 71 | if ( |
||
| 72 | (int) $this->piVars['page'] > 0 |
||
| 73 | || empty($this->piVars['page']) |
||
| 74 | ) { |
||
| 75 | $this->piVars['page'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange((int) $this->piVars['page'], 1, $this->doc->numPages, 1); |
||
| 76 | } else { |
||
| 77 | $this->piVars['page'] = array_search($this->piVars['page'], $this->doc->physicalStructure); |
||
| 78 | } |
||
| 79 | } |
||
| 80 | |||
| 81 | // Quit if no fulltext file is present |
||
| 82 | $fullTextFile = $this->doc->physicalStructureInfo[$this->doc->physicalStructure[$this->piVars['page']]]['files'][$this->conf['fileGrpFulltext']]; |
||
| 83 | if (empty($fullTextFile)) { |
||
| 84 | return $content; |
||
| 85 | } |
||
| 86 | |||
| 87 | // Load template file. |
||
| 88 | $this->getTemplate(); |
||
| 89 | |||
| 90 | // Configure @action URL for form. |
||
| 91 | $linkConf = [ |
||
| 92 | 'parameter' => $GLOBALS['TSFE']->id, |
||
| 93 | 'forceAbsoluteUrl' => 1 |
||
| 94 | ]; |
||
| 95 | |||
| 96 | $encryptedSolr = $this->getEncryptedCoreName(); |
||
| 97 | // Fill markers. |
||
| 98 | $markerArray = [ |
||
| 99 | '###ACTION_URL###' => $this->cObj->typoLink_URL($linkConf), |
||
| 100 | '###LABEL_QUERY###' => $this->pi_getLL('label.query'), |
||
| 101 | '###LABEL_DELETE_SEARCH###' => $this->pi_getLL('label.delete_search'), |
||
| 102 | '###LABEL_LOADING###' => $this->pi_getLL('label.loading'), |
||
| 103 | '###LABEL_SUBMIT###' => $this->pi_getLL('label.submit'), |
||
| 104 | '###LABEL_SEARCH_IN_DOCUMENT###' => $this->pi_getLL('label.searchInDocument'), |
||
| 105 | '###LABEL_NEXT###' => $this->pi_getLL('label.next'), |
||
| 106 | '###LABEL_PREVIOUS###' => $this->pi_getLL('label.previous'), |
||
| 107 | '###LABEL_PAGE###' => $this->pi_getLL('label.logicalPage'), |
||
| 108 | '###CURRENT_DOCUMENT###' => $this->doc->uid, |
||
| 109 | '###SOLR_ENCRYPTED###' => isset($encryptedSolr['encrypted']) ? $encryptedSolr['encrypted'] : '', |
||
| 110 | '###SOLR_HASH###' => isset($encryptedSolr['hash']) ? $encryptedSolr['hash'] : '', |
||
| 111 | ]; |
||
| 112 | |||
| 113 | $content .= $this->templateService->substituteMarkerArray($this->template, $markerArray); |
||
| 114 | return $this->pi_wrapInBaseClass($content); |
||
| 115 | } |
||
| 148 |