We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Conditions | 9 |
| Paths | 17 |
| Total Lines | 66 |
| Code Lines | 27 |
| Lines | 39 |
| Ratio | 59.09 % |
| 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 |
||
| 35 | public function main($content, $conf) { |
||
| 36 | |||
| 37 | $this->init($conf); |
||
| 38 | |||
| 39 | // Merge configuration with conf array of toolbox. |
||
| 40 | $this->conf = tx_dlf_helper::array_merge_recursive_overrule($this->cObj->data['conf'], $this->conf); |
||
|
|
|||
| 41 | |||
| 42 | // Load current document. |
||
| 43 | $this->loadDocument(); |
||
| 44 | |||
| 45 | View Code Duplication | if ($this->doc === NULL || $this->doc->numPages < 1 || empty($this->conf['fileGrpFulltext'])) { |
|
| 46 | |||
| 47 | // Quit without doing anything if required variables are not set. |
||
| 48 | return $content; |
||
| 49 | |||
| 50 | } else { |
||
| 51 | |||
| 52 | if (!empty($this->piVars['logicalPage'])) { |
||
| 53 | |||
| 54 | $this->piVars['page'] = $this->doc->getPhysicalPage($this->piVars['logicalPage']); |
||
| 55 | // The logical page parameter should not appear again |
||
| 56 | unset($this->piVars['logicalPage']); |
||
| 57 | |||
| 58 | } |
||
| 59 | |||
| 60 | // Set default values if not set. |
||
| 61 | // $this->piVars['page'] may be integer or string (physical structure @ID) |
||
| 62 | if ( (int)$this->piVars['page'] > 0 || empty($this->piVars['page'])) { |
||
| 63 | |||
| 64 | $this->piVars['page'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange((int) $this->piVars['page'], 1, $this->doc->numPages, 1); |
||
| 65 | |||
| 66 | } else { |
||
| 67 | |||
| 68 | $this->piVars['page'] = array_search($this->piVars['page'], $this->doc->physicalStructure); |
||
| 69 | |||
| 70 | } |
||
| 71 | |||
| 72 | $this->piVars['double'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->piVars['double'], 0, 1, 0); |
||
| 73 | |||
| 74 | } |
||
| 75 | |||
| 76 | // Load template file. |
||
| 77 | View Code Duplication | if (!empty($this->conf['toolTemplateFile'])) { |
|
| 78 | |||
| 79 | $this->template = $this->cObj->getSubpart($this->cObj->fileResource($this->conf['toolTemplateFile']), '###TEMPLATE###'); |
||
| 80 | |||
| 81 | } else { |
||
| 82 | |||
| 83 | $this->template = $this->cObj->getSubpart($this->cObj->fileResource('EXT:dlf/plugins/toolbox/tools/fulltext/template.tmpl'), '###TEMPLATE###'); |
||
| 84 | |||
| 85 | } |
||
| 86 | |||
| 87 | |||
| 88 | $fullTextFile = $this->doc->physicalStructureInfo[$this->doc->physicalStructure[$this->piVars['page']]]['files'][$this->conf['fileGrpFulltext']]; |
||
| 89 | |||
| 90 | if (!empty($fullTextFile)) { |
||
| 91 | $markerArray['###FULLTEXT_SELECT###'] = '<a class="select switchoff" id="tx-dlf-tools-fulltext" title="" data-dic="fulltext-on:' |
||
|
1 ignored issue
–
show
|
|||
| 92 | .$this->pi_getLL('fulltext-on', '', TRUE).';fulltext-off:' |
||
| 93 | .$this->pi_getLL('fulltext-off', '', TRUE).'"> </a>'; |
||
| 94 | } else { |
||
| 95 | $markerArray['###FULLTEXT_SELECT###'] = '<span class="no-fulltext">' . $this->pi_getLL('fulltext-not-available', '', TRUE) . '</span>'; |
||
| 96 | } |
||
| 97 | |||
| 98 | $content .= $this->cObj->substituteMarkerArray($this->template, $markerArray); |
||
| 99 | |||
| 100 | return $this->pi_wrapInBaseClass($content); |
||
| 101 | |||
| 105 |