| Conditions | 8 |
| Paths | 17 |
| Total Lines | 51 |
| 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 |
||
| 129 | protected function getRevisions(&$first, &$hasNext) |
||
| 130 | { |
||
| 131 | global $INFO, $conf; |
||
| 132 | |||
| 133 | if ($this->id != $INFO['id']) { |
||
| 134 | return parent::getRevisions($first, $hasNext); |
||
| 135 | } |
||
| 136 | |||
| 137 | $changelog =& $this->changelog; |
||
| 138 | |||
| 139 | $revisions = []; |
||
| 140 | |||
| 141 | /* we need to get one additional log entry to be able to |
||
| 142 | * decide if this is the last page or is there another one. |
||
| 143 | * see also Ui\Recent::getRecents() |
||
| 144 | */ |
||
| 145 | $revlist = $changelog->getRevisions($first, $conf['recent'] +1); |
||
| 146 | if (count($revlist) == 0 && $first != 0) { |
||
| 147 | $first = 0; |
||
| 148 | $revlist = $changelog->getRevisions($first, $conf['recent'] +1); |
||
| 149 | } |
||
| 150 | $exists = $INFO['exists']; |
||
| 151 | if ($first == 0 && $exists) { |
||
| 152 | // add current page as revision[0] |
||
| 153 | $revisions[] = array( |
||
| 154 | 'date' => $INFO['lastmod'], |
||
| 155 | 'ip' => null, |
||
| 156 | 'type' => $INFO['meta']['last_change']['type'], |
||
| 157 | 'id' => $INFO['id'], |
||
| 158 | 'user' => $INFO['editor'], |
||
| 159 | 'sum' => $INFO['sum'], |
||
| 160 | 'extra' => null, |
||
| 161 | 'sizechange' => $INFO['meta']['last_change']['sizechange'], |
||
| 162 | 'item' => $this->item, |
||
| 163 | 'current' => true, |
||
| 164 | ); |
||
| 165 | } |
||
| 166 | |||
| 167 | // decide if this is the last page or is there another one |
||
| 168 | $hasNext = false; |
||
| 169 | if (count($revlist) > $conf['recent']) { |
||
| 170 | $hasNext = true; |
||
| 171 | array_pop($revlist); // remove one additional log entry |
||
| 172 | } |
||
| 173 | |||
| 174 | // append each revison info array to the revisions |
||
| 175 | foreach ($revlist as $rev) { |
||
| 176 | $revisions[] = $changelog->getRevisionInfo($rev) + array('item' => $this->item); |
||
| 177 | } |
||
| 178 | return $revisions; |
||
| 179 | } |
||
| 180 | |||
| 182 |