| 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 |
||
| 92 | protected function setPagination($iCrtPgNo, $inRecPrPg, $iAllRec, $bKpFlPg = true) |
||
|
|
|||
| 93 | { |
||
| 94 | $sReturn = null; |
||
| 95 | $iRecPrPg = min($iRecPrPg, $iAllRec); |
||
| 96 | $iStartingPageRecord = $this->setStartingPageRecord($iCrtPgNo, $iRecPrPg, $iAllRec, $bKpFlPg); |
||
| 97 | $sReturn .= '<span style="float:left;font-size:smaller;margin-top:1px; margin-right:1px;">' |
||
| 98 | . $this->setStringIntoTag($iAllRec, 'b') |
||
| 99 | . $this->lclMsgCmn('i18n_RecordsAvailableNowDisplaying') |
||
| 100 | . $this->setStringIntoTag(($iStartingPageRecord + 1), 'b') |
||
| 101 | . ' - ' . $this->setStringIntoTag(min($iAllRec, ($iStartingPageRecord + $iRecPrPg)), 'b') |
||
| 102 | . ' </span>'; |
||
| 103 | switch ($iCrtPgNo) { |
||
| 104 | case 'first': |
||
| 105 | $iCrtPgNo = ceil(($iStartingPageRecord + 1 ) / $iRecPrPg); |
||
| 106 | break; |
||
| 107 | case 'last': |
||
| 108 | $iCrtPgNo = ceil($iAllRec / $iRecPrPg); |
||
| 109 | break; |
||
| 110 | } |
||
| 111 | $sReturn .= '<span style="float:right;font-size:smaller;margin-top:1px; margin-right:1px;">'; |
||
| 112 | $iNumberOfPages = ceil($iAllRec / $iRecPrPg); |
||
| 113 | $sAdditionalArguments = ''; |
||
| 114 | if (isset($_GET)) { |
||
| 115 | if ($_GET != ['page' => @$_GET['page']]) { |
||
| 116 | $sAdditionalArguments = '&' |
||
| 117 | . $this->setArrayToStringForUrl('&', $_GET, ['page', 'action', 'server_action']); |
||
| 118 | } |
||
| 119 | if (isset($_GET['page'])) { |
||
| 120 | $iCrtPgNo = $_GET['page']; |
||
| 121 | } |
||
| 122 | } |
||
| 123 | if ($iCrtPgNo != 1) { |
||
| 124 | $sReturn .= $this->setStringIntoTag($this->lclMsgCmn('i18n_Previous'), 'a', [ |
||
| 125 | 'href' => ('?page=' . ($iCrtPgNo - 1 ) . $sAdditionalArguments ), |
||
| 126 | 'class' => 'pagination' |
||
| 127 | ]); |
||
| 128 | } else { |
||
| 129 | $sReturn .= $this->setStringIntoTag($this->lclMsgCmn('i18n_Previous'), 'span', [ |
||
| 130 | 'class' => 'pagination_inactive' |
||
| 131 | ]); |
||
| 132 | } |
||
| 133 | $pages2display = []; |
||
| 134 | for ($counter = 1; $counter <= $iNumberOfPages; $counter++) { |
||
| 135 | $pages2display[$counter] = $counter; |
||
| 136 | } |
||
| 137 | $sReturn .= '<span class="pagination"><form method="get" action="' . $_SERVER['SCRIPT_NAME'] . '">'; |
||
| 138 | $sReturn .= $this->setArrayToSelect($pages2display, @$_REQUEST['page'] |
||
| 139 | , 'page', ['size' => 1, 'autosubmit', 'id_no' => mt_rand()]); |
||
| 140 | if (isset($_GET)) { |
||
| 141 | foreach ($_GET as $key => $value) { |
||
| 142 | if ($key != 'page') { |
||
| 143 | if (is_array($value)) { |
||
| 144 | foreach ($value as $value2) { |
||
| 145 | $sReturn .= $this->setStringIntoShortTag('input', [ |
||
| 146 | 'type' => 'hidden', |
||
| 147 | 'name' => $key . '[]', |
||
| 148 | 'value' => $value2, |
||
| 149 | ]); |
||
| 150 | } |
||
| 151 | } else { |
||
| 152 | $sReturn .= $this->setStringIntoShortTag('input', [ |
||
| 153 | 'type' => 'hidden', |
||
| 154 | 'name' => $key, |
||
| 155 | 'value' => $value, |
||
| 156 | ]); |
||
| 157 | } |
||
| 158 | } |
||
| 159 | } |
||
| 160 | } |
||
| 161 | $sReturn .= '</form></span>'; |
||
| 162 | if ($iCrtPgNo != $iNumberOfPages) { |
||
| 163 | $sReturn .= $this->setStringIntoTag($this->lclMsgCmn('i18n_Next'), 'a', [ |
||
| 164 | 'href' => ('?page=' . ($iCrtPgNo + 1 ) . $sAdditionalArguments ), |
||
| 165 | 'class' => 'pagination', |
||
| 166 | ]); |
||
| 167 | } else { |
||
| 168 | $sReturn .= $this->setStringIntoTag($this->lclMsgCmn('i18n_Next'), 'span', [ |
||
| 169 | 'class' => 'pagination_inactive', |
||
| 170 | ]); |
||
| 171 | } |
||
| 172 | $sReturn .= '</span>'; |
||
| 173 | return $sReturn; |
||
| 174 | } |
||
| 209 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.