We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Conditions | 13 |
| Paths | 34 |
| Total Lines | 64 |
| Code Lines | 40 |
| 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 |
||
| 137 | public function main($content, $conf) |
||
| 138 | { |
||
| 139 | $this->init($conf); |
||
| 140 | $this->loadDocument(); |
||
| 141 | if ( |
||
| 142 | $this->doc === null |
||
| 143 | || $this->doc->numPages < 1 |
||
| 144 | || empty($this->conf['fileGrpThumbs']) |
||
| 145 | ) { |
||
| 146 | // Quit without doing anything if required variables are not set. |
||
| 147 | return $content; |
||
| 148 | } else { |
||
| 149 | // Set default values for page if not set. |
||
| 150 | $this->piVars['pointer'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->piVars['pointer'], 0, $this->doc->numPages, 0); |
||
| 151 | } |
||
| 152 | // Load template file. |
||
| 153 | $this->getTemplate(); |
||
| 154 | $entryTemplate = $this->templateService->getSubpart($this->template, '###ENTRY###'); |
||
| 155 | if (empty($entryTemplate)) { |
||
| 156 | Helper::devLog('No template subpart for list entry found', DEVLOG_SEVERITY_WARNING); |
||
| 157 | // Quit without doing anything if required variables are not set. |
||
| 158 | return $content; |
||
| 159 | } |
||
| 160 | if (!empty($this->piVars['logicalPage'])) { |
||
| 161 | $this->piVars['page'] = $this->doc->getPhysicalPage($this->piVars['logicalPage']); |
||
| 162 | // The logical page parameter should not appear |
||
| 163 | unset($this->piVars['logicalPage']); |
||
| 164 | } |
||
| 165 | // Set some variable defaults. |
||
| 166 | // $this->piVars['page'] may be integer or string (physical structure @ID) |
||
| 167 | if ( |
||
| 168 | (int) $this->piVars['page'] > 0 |
||
| 169 | || empty($this->piVars['page']) |
||
| 170 | ) { |
||
| 171 | $this->piVars['page'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange((int) $this->piVars['page'], 1, $this->doc->numPages, 1); |
||
| 172 | } else { |
||
| 173 | $this->piVars['page'] = array_search($this->piVars['page'], $this->doc->physicalStructure); |
||
| 174 | } |
||
| 175 | if (!empty($this->piVars['page'])) { |
||
| 176 | $this->piVars['pointer'] = intval(floor(($this->piVars['page'] - 1) / $this->conf['limit'])); |
||
| 177 | } |
||
| 178 | if ( |
||
| 179 | !empty($this->piVars['pointer']) |
||
| 180 | && (($this->piVars['pointer'] * $this->conf['limit']) + 1) <= $this->doc->numPages |
||
| 181 | ) { |
||
| 182 | $this->piVars['pointer'] = max(intval($this->piVars['pointer']), 0); |
||
| 183 | } else { |
||
| 184 | $this->piVars['pointer'] = 0; |
||
| 185 | } |
||
| 186 | // Iterate through visible page set and display thumbnails. |
||
| 187 | for ($i = $this->piVars['pointer'] * $this->conf['limit'], $j = ($this->piVars['pointer'] + 1) * $this->conf['limit']; $i < $j; $i++) { |
||
| 188 | // +1 because page counting starts at 1. |
||
| 189 | $number = $i + 1; |
||
| 190 | if ($number > $this->doc->numPages) { |
||
| 191 | break; |
||
| 192 | } else { |
||
| 193 | $content .= $this->getEntry($number, $entryTemplate); |
||
| 194 | } |
||
| 195 | } |
||
| 196 | // Render page browser. |
||
| 197 | $markerArray['###PAGEBROWSER###'] = $this->getPageBrowser(); |
||
| 198 | // Merge everything with template. |
||
| 199 | $content = $this->templateService->substituteMarkerArray($this->templateService->substituteSubpart($this->template, '###ENTRY###', $content, true), $markerArray); |
||
| 200 | return $this->pi_wrapInBaseClass($content); |
||
| 201 | } |
||
| 203 |
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.