Conditions | 13 |
Paths | 9 |
Total Lines | 42 |
Code Lines | 27 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 |
||
40 | public function facetwp_pager_html( $output, $params ) { |
||
41 | $output = ''; |
||
42 | $page = (int) $params['page']; |
||
43 | $per_page = (int) $params['per_page']; |
||
44 | $total_pages = (int) $params['total_pages']; |
||
45 | |||
46 | if ( 1 < $total_pages ) { |
||
47 | $output .= '<div class="lsx-pagination-wrapper facetwp-custom">'; |
||
48 | $output .= '<div class="lsx-pagination">'; |
||
49 | // $output .= '<span class="pages">Page '. $page .' of '. $total_pages .'</span>'; |
||
50 | |||
51 | if ( 1 < $page ) { |
||
52 | $output .= '<a class="prev page-numbers facetwp-page" rel="prev" data-page="' . ( $page - 1 ) . '">«</a>'; |
||
53 | } |
||
54 | |||
55 | $temp = false; |
||
56 | |||
57 | for ( $i = 1; $i <= $total_pages; $i++ ) { |
||
58 | if ( $i == $page ) { |
||
59 | $output .= '<span class="page-numbers current">' . $i . '</span>'; |
||
60 | } elseif ( ( $page - 2 ) < $i && ( $page + 2 ) > $i ) { |
||
61 | $output .= '<a class="page-numbers facetwp-page" data-page="' . $i . '">' . $i . '</a>'; |
||
62 | } elseif ( ( $page - 2 ) >= $i && $page > 2 ) { |
||
63 | if ( ! $temp ) { |
||
64 | $output .= '<span class="page-numbers dots">...</span>'; |
||
65 | $temp = true; |
||
66 | } |
||
67 | } elseif ( ( $page + 2 ) <= $i && ( $page + 2 ) <= $total_pages ) { |
||
68 | $output .= '<span class="page-numbers dots">...</span>'; |
||
69 | break; |
||
70 | } |
||
71 | } |
||
72 | |||
73 | if ( $page < $total_pages ) { |
||
74 | $output .= '<a class="next page-numbers facetwp-page" rel="next" data-page="' . ( $page + 1 ) . '">»</a>'; |
||
75 | } |
||
76 | |||
77 | $output .= '</div>'; |
||
78 | $output .= '</div>'; |
||
79 | } |
||
80 | |||
81 | return $output; |
||
82 | } |
||
148 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.