| Conditions | 14 |
| Paths | 240 |
| Total Lines | 82 |
| 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 |
||
| 48 | protected function setPagination($iCrtPgNo, $inRecPrPg, $iAllRec, $bKpFlPg = true) |
||
|
|
|||
| 49 | { |
||
| 50 | $sReturn = null; |
||
| 51 | $iRecPrPg = min($iRecPrPg, $iAllRec); |
||
| 52 | $iStartingPageRecord = $this->setStartingPageRecord($iCrtPgNo, $iRecPrPg, $iAllRec, $bKpFlPg); |
||
| 53 | $sReturn .= '<span style="float:left;font-size:smaller;margin-top:1px; margin-right:1px;">' |
||
| 54 | . $this->setStringIntoTag($iAllRec, 'b') |
||
| 55 | . $this->lclMsgCmn('i18n_RecordsAvailableNowDisplaying') |
||
| 56 | . $this->setStringIntoTag(($iStartingPageRecord + 1), 'b') |
||
| 57 | . ' - ' . $this->setStringIntoTag(min($iAllRec, ($iStartingPageRecord + $iRecPrPg)), 'b') |
||
| 58 | . ' </span>'; |
||
| 59 | switch ($iCrtPgNo) { |
||
| 60 | case 'first': |
||
| 61 | $iCrtPgNo = ceil(($iStartingPageRecord + 1 ) / $iRecPrPg); |
||
| 62 | break; |
||
| 63 | case 'last': |
||
| 64 | $iCrtPgNo = ceil($iAllRec / $iRecPrPg); |
||
| 65 | break; |
||
| 66 | } |
||
| 67 | $sReturn .= '<span style="float:right;font-size:smaller;margin-top:1px; margin-right:1px;">'; |
||
| 68 | $iNumberOfPages = ceil($iAllRec / $iRecPrPg); |
||
| 69 | $sAdditionalArguments = ''; |
||
| 70 | if (isset($_GET)) { |
||
| 71 | if ($_GET != ['page' => @$_GET['page']]) { |
||
| 72 | $sAdditionalArguments = '&' |
||
| 73 | . $this->setArrayToStringForUrl('&', $_GET, ['page', 'action', 'server_action']); |
||
| 74 | } |
||
| 75 | if (isset($_GET['page'])) { |
||
| 76 | $iCrtPgNo = $_GET['page']; |
||
| 77 | } |
||
| 78 | } |
||
| 79 | if ($iCrtPgNo != 1) { |
||
| 80 | $sReturn .= $this->setStringIntoTag($this->lclMsgCmn('i18n_Previous'), 'a', [ |
||
| 81 | 'href' => ('?page=' . ($iCrtPgNo - 1 ) . $sAdditionalArguments ), |
||
| 82 | 'class' => 'pagination' |
||
| 83 | ]); |
||
| 84 | } else { |
||
| 85 | $sReturn .= $this->setStringIntoTag($this->lclMsgCmn('i18n_Previous'), 'span', [ |
||
| 86 | 'class' => 'pagination_inactive' |
||
| 87 | ]); |
||
| 88 | } |
||
| 89 | $pages2display = []; |
||
| 90 | for ($counter = 1; $counter <= $iNumberOfPages; $counter++) { |
||
| 91 | $pages2display[$counter] = $counter; |
||
| 92 | } |
||
| 93 | $sReturn .= '<span class="pagination"><form method="get" action="' . $_SERVER['SCRIPT_NAME'] . '">'; |
||
| 94 | $sReturn .= $this->setArrayToSelect($pages2display, @$_REQUEST['page'] |
||
| 95 | , 'page', ['size' => 1, 'autosubmit', 'id_no' => mt_rand()]); |
||
| 96 | if (isset($_GET)) { |
||
| 97 | foreach ($_GET as $key => $value) { |
||
| 98 | if ($key != 'page') { |
||
| 99 | if (is_array($value)) { |
||
| 100 | foreach ($value as $value2) { |
||
| 101 | $sReturn .= $this->setStringIntoShortTag('input', [ |
||
| 102 | 'type' => 'hidden', |
||
| 103 | 'name' => $key . '[]', |
||
| 104 | 'value' => $value2, |
||
| 105 | ]); |
||
| 106 | } |
||
| 107 | } else { |
||
| 108 | $sReturn .= $this->setStringIntoShortTag('input', [ |
||
| 109 | 'type' => 'hidden', |
||
| 110 | 'name' => $key, |
||
| 111 | 'value' => $value, |
||
| 112 | ]); |
||
| 113 | } |
||
| 114 | } |
||
| 115 | } |
||
| 116 | } |
||
| 117 | $sReturn .= '</form></span>'; |
||
| 118 | if ($iCrtPgNo != $iNumberOfPages) { |
||
| 119 | $sReturn .= $this->setStringIntoTag($this->lclMsgCmn('i18n_Next'), 'a', [ |
||
| 120 | 'href' => ('?page=' . ($iCrtPgNo + 1 ) . $sAdditionalArguments ), |
||
| 121 | 'class' => 'pagination', |
||
| 122 | ]); |
||
| 123 | } else { |
||
| 124 | $sReturn .= $this->setStringIntoTag($this->lclMsgCmn('i18n_Next'), 'span', [ |
||
| 125 | 'class' => 'pagination_inactive', |
||
| 126 | ]); |
||
| 127 | } |
||
| 128 | $sReturn .= '</span>'; |
||
| 129 | return $sReturn; |
||
| 130 | } |
||
| 165 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.