| Conditions | 14 | 
| Paths | 1 | 
| Total Lines | 57 | 
| Code Lines | 41 | 
| 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 | ||
| 127 | protected static function request() | ||
| 128 |     { | ||
| 129 |         $export = function(){ | ||
| 130 | $exp = filter_input(INPUT_GET, 'export', FILTER_SANITIZE_STRING); | ||
| 131 |             return in_array($exp, self::config('SAVES')) ? $exp : false; | ||
|  | |||
| 132 | }; | ||
| 133 |         $order_dir = function(){ | ||
| 134 | $reset = filter_has_var(INPUT_GET, 'col') ? 'asc' : null; | ||
| 135 | return | ||
| 136 | in_array(filter_input(INPUT_GET, 'ord'), ['asc', 'desc']) ? | ||
| 137 | filter_input(INPUT_GET, 'ord') : | ||
| 138 | ($reset ?: self::$t['order']['dir']); | ||
| 139 | }; | ||
| 140 |         $order_col = function(){ | ||
| 141 | $col = filter_input(INPUT_GET, 'col', FILTER_VALIDATE_INT); | ||
| 142 |             if ($col) { | ||
| 143 | return isset(self::$cols[$col][2]['sort']) ? | ||
| 144 | self::$cols[$col][2]['sort'] : | ||
| 145 | self::$cols[$col][1]; | ||
| 146 | } | ||
| 147 | return self::$t['order']['col']; | ||
| 148 | }; | ||
| 149 |         $filter = function(){ | ||
| 150 | $filter = filter_input(INPUT_GET, 'filter') ?: false; | ||
| 151 |             if ($filter) { | ||
| 152 | $by = filter_input(INPUT_GET, 'filter-by', FILTER_VALIDATE_INT); | ||
| 153 |                 if ($by === false || is_null($by)) { | ||
| 154 |                     $by = self::request('FilterByAll'); | ||
| 155 |                 } else { | ||
| 156 | $by = self::$cols[$by][1]; | ||
| 157 | } | ||
| 158 |                 $by = 'CONCAT(" ",' . $by . ', " ")'; | ||
| 159 |                 if (self::config('FILTER_CASE_SENSITIVE') !== true) { | ||
| 160 |                     $by .= ' COLLATE ' . self::config('DB_COLLATION_CI'); | ||
| 161 | } | ||
| 162 | $filter = $by . ' LIKE ' . '"%' . $filter . '%"'; | ||
| 163 | } | ||
| 164 | return $filter; | ||
| 165 | }; | ||
| 166 |         $page = function(){ | ||
| 167 | return filter_has_var(INPUT_GET, 'pg') && self::$export == false ? | ||
| 168 | (int)filter_input(INPUT_GET, 'pg', FILTER_SANITIZE_NUMBER_INT) : | ||
| 169 | self::$t['page']; | ||
| 170 | }; | ||
| 171 | |||
| 172 | self::$export = $export(); | ||
| 173 | |||
| 174 | $t = [ | ||
| 175 | 'order' => [ | ||
| 176 | 'dir' => $order_dir(), | ||
| 177 | 'col' => $order_col() | ||
| 178 | ], | ||
| 179 | 'filter' => $filter(), | ||
| 180 | 'page' => $page() | ||
| 181 | ]; | ||
| 182 | //dd(array_merge(self::$t, $t)); | ||
| 183 | return array_merge(self::$t, $t); | ||
| 184 | } | ||
| 186 |