Conditions | 10 |
Paths | 109 |
Total Lines | 27 |
Code Lines | 20 |
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 |
||
26 | public static function paging($records, $pageURL, $start = 0, $additional = '', $maxshown = 50, $numpagesshown = 11){ |
||
27 | if($records > $maxshown){ |
||
28 | if($start >= 1){self::$current = $start;}else{self::$current = 1;} |
||
29 | self::$lastpage = ceil($records / $maxshown); |
||
30 | |||
31 | if(!empty($additional)){$additional = 'search='.$additional.'&';} |
||
32 | |||
33 | self::getPage($records, $maxshown, $numpagesshown); |
||
34 | $paging = '<ul class="pagination">'; |
||
35 | if(self::$current != 1){ |
||
36 | if(self::$current != 2){$paging.= '<li><a href="'.$pageURL.'?'.$additional.'">«</a></li>';} |
||
37 | $paging.= '<li><a href="'.$pageURL.'?'.$additional.'page='.($start - 1).'"><</a></li>'; |
||
38 | } |
||
39 | while(self::$page <= self::$lastpage){ |
||
40 | if(self::$current == self::$page){$curselect = ' class="active"';}else{$curselect = '';} |
||
41 | $paging.= '<li'.$curselect.'><a href="'.$pageURL.'?'.$additional.'page='.self::$page.'">'.self::$page.'</a></li>'; |
||
42 | self::$page = (self::$page + 1); |
||
43 | } |
||
44 | if(self::$current != self::$lastpage){ |
||
45 | $paging.= '<li><a href="'.$pageURL.'?'.$additional.'page='.($start + 1).'">></a></li>'; |
||
46 | if(self::$current != (self::$lastpage - 1)){$paging.= '<li><a href="'.$pageURL.'?'.$additional.'page='.ceil($records / $maxshown).'">»</a></li>';} |
||
47 | } |
||
48 | $paging.= '</ul>'; |
||
49 | return $paging; |
||
50 | } |
||
51 | return false; |
||
52 | } |
||
53 | |||
75 |