We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
Conditions | 13 |
Paths | 576 |
Total Lines | 49 |
Code Lines | 34 |
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 |
||
91 | protected function getPageLink() |
||
92 | { |
||
93 | $page1Link = ''; |
||
94 | $page2Link = ''; |
||
95 | $pageNumber = $this->piVars['page']; |
||
96 | // Get image link. |
||
97 | $details = $this->doc->physicalStructureInfo[$this->doc->physicalStructure[$pageNumber]]; |
||
98 | $file = $details['files'][$this->conf['fileGrpDownload']]; |
||
99 | if (!empty($file)) { |
||
100 | $page1Link = $this->doc->getFileLocation($file); |
||
101 | } |
||
102 | // Get second page, too, if double page view is activated. |
||
103 | if ( |
||
104 | $this->piVars['double'] |
||
105 | && $pageNumber < $this->doc->numPages |
||
106 | ) { |
||
107 | $details = $this->doc->physicalStructureInfo[$this->doc->physicalStructure[$pageNumber + 1]]; |
||
108 | $file = $details['files'][$this->conf['fileGrpDownload']]; |
||
109 | if (!empty($file)) { |
||
110 | $page2Link = $this->doc->getFileLocation($file); |
||
111 | } |
||
112 | } |
||
113 | if ( |
||
114 | empty($page1Link) |
||
115 | && empty($page2Link) |
||
116 | ) { |
||
117 | Helper::devLog('File not found in fileGrp "' . $this->conf['fileGrpDownload'] . '"', DEVLOG_SEVERITY_WARNING); |
||
118 | } |
||
119 | // Wrap URLs with HTML. |
||
120 | $linkConf = [ |
||
121 | 'forceAbsoluteUrl' => !empty($this->conf['forceAbsoluteUrl']) ? 1 : 0, |
||
122 | 'forceAbsoluteUrl.' => ['scheme' => !empty($this->conf['forceAbsoluteUrl']) && !empty($this->conf['forceAbsoluteUrlHttps']) ? 'https' : 'http'] |
||
123 | ]; |
||
124 | if (!empty($page1Link)) { |
||
125 | $linkConf['parameter'] = $page1Link; |
||
126 | if ($this->piVars['double']) { |
||
127 | $linkConf['title'] = $this->pi_getLL('leftPage', ''); |
||
128 | $page1Link = $this->cObj->typoLink($this->pi_getLL('leftPage', ''), $linkConf); |
||
129 | } else { |
||
130 | $linkConf['title'] = $this->pi_getLL('singlePage', ''); |
||
131 | $page1Link = $this->cObj->typoLink($this->pi_getLL('singlePage', ''), $linkConf); |
||
132 | } |
||
133 | } |
||
134 | if (!empty($page2Link)) { |
||
135 | $linkConf['parameter'] = $page2Link; |
||
136 | $linkConf['title'] = $this->pi_getLL('rightPage', ''); |
||
137 | $page2Link = $this->cObj->typoLink($this->pi_getLL('rightPage', ''), $linkConf); |
||
138 | } |
||
139 | return $page1Link . $page2Link; |
||
140 | } |
||
176 |