We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Conditions | 10 |
| Paths | 72 |
| Total Lines | 35 |
| Code Lines | 24 |
| 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 |
||
| 80 | protected function getPageLink() { |
||
| 81 | $page1Link = ''; |
||
| 82 | $page2Link = ''; |
||
| 83 | $pageNumber = $this->piVars['page']; |
||
| 84 | // Get image link. |
||
| 85 | $details = $this->doc->physicalStructureInfo[$this->doc->physicalStructure[$pageNumber]]; |
||
| 86 | $file = $details['files'][$this->conf['fileGrpDownload']]; |
||
| 87 | if (!empty($file)) { |
||
| 88 | $page1Link = $this->doc->getFileLocation($file); |
||
| 89 | } |
||
| 90 | // Get second page, too, if double page view is activated. |
||
| 91 | if ($this->piVars['double'] |
||
| 92 | && $pageNumber < $this->doc->numPages) { |
||
| 93 | $details = $this->doc->physicalStructureInfo[$this->doc->physicalStructure[$pageNumber + 1]]; |
||
| 94 | $file = $details['files'][$this->conf['fileGrpDownload']]; |
||
| 95 | if (!empty($file)) { |
||
| 96 | $page2Link = $this->doc->getFileLocation($file); |
||
| 97 | } |
||
| 98 | } |
||
| 99 | if (empty($page1Link) |
||
| 100 | && empty($page2Link)) { |
||
| 101 | Helper::devLog('File not found in fileGrp "'.$this->conf['fileGrpDownload'].'"', DEVLOG_SEVERITY_WARNING); |
||
| 102 | } |
||
| 103 | // Wrap URLs with HTML. |
||
| 104 | if (!empty($page1Link)) { |
||
| 105 | if ($this->piVars['double']) { |
||
| 106 | $page1Link = $this->cObj->typoLink($this->pi_getLL('leftPage', ''), ['parameter' => $page1Link, 'title' => $this->pi_getLL('leftPage', '')]); |
||
| 107 | } else { |
||
| 108 | $page1Link = $this->cObj->typoLink($this->pi_getLL('singlePage', ''), ['parameter' => $page1Link, 'title' => $this->pi_getLL('singlePage', '')]); |
||
| 109 | } |
||
| 110 | } |
||
| 111 | if (!empty($page2Link)) { |
||
| 112 | $page2Link = $this->cObj->typoLink($this->pi_getLL('rightPage', ''), ['parameter' => $page2Link, 'title' => $this->pi_getLL('rightPage', '')]); |
||
| 113 | } |
||
| 114 | return $page1Link.$page2Link; |
||
| 115 | } |
||
| 144 |