| Conditions | 23 | 
| Paths | 22 | 
| Total Lines | 65 | 
| Code Lines | 51 | 
| 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 | ||
| 68 | final static function request($make = null) | ||
|  | |||
| 69 |     { | ||
| 70 |         switch ($make) { | ||
| 71 | default: | ||
| 72 | |||
| 73 |                 self::$export = self::request('Export'); | ||
| 74 | |||
| 75 | $t = [ | ||
| 76 | 'order' => [ | ||
| 77 |                             'dir' => self::request('OrderDir'), | ||
| 78 |                             'col' => self::request('OrderCol') | ||
| 79 | ], | ||
| 80 |                     'filter' => self::request('Filter'), | ||
| 81 |                     'page' => self::request('Page') | ||
| 82 | ]; | ||
| 83 | //dd(array_merge(self::$t, $t)); | ||
| 84 | return array_merge(self::$t, $t); | ||
| 85 | |||
| 86 | case 'Filter': | ||
| 87 | $filter = filter_input(INPUT_GET, 'filter') ?: false; | ||
| 88 |                 if ($filter) { | ||
| 89 | $by = filter_input(INPUT_GET, 'filter-by', FILTER_VALIDATE_INT); | ||
| 90 |                     if ($by === false || is_null($by)) { | ||
| 91 | $by = self::requestFilterByAll(); | ||
| 92 |                     } else { | ||
| 93 | $by = self::$cols[$by][1]; | ||
| 94 | } | ||
| 95 |                     $by = 'CONCAT(" ",' . $by . ', " ")'; | ||
| 96 |                     if (self::config('FILTER_CASE_SENSITIVE') !== true) { | ||
| 97 |                         $by .= ' COLLATE ' . self::config('DB_COLLATION_CI'); | ||
| 98 | } | ||
| 99 | $filter = $by . ' LIKE ' . '"%' . $filter . '%"'; | ||
| 100 | } | ||
| 101 | return $filter; | ||
| 102 | case 'FilterByAll': | ||
| 103 | $by = []; | ||
| 104 |                 foreach (self::$cols as $v) { | ||
| 105 |                     if (isset($v[2]['sort']) && $v[2]['sort'] === false) { | ||
| 106 | continue; | ||
| 107 | } | ||
| 108 |                     $by[] = 'IFNULL(' . $v[1] . ', "")'; | ||
| 109 | } | ||
| 110 |                 return 'CONCAT(' . implode(',', $by) . ')'; | ||
| 111 | case 'OrderCol': | ||
| 112 | $col = filter_input(INPUT_GET, 'col', FILTER_VALIDATE_INT); | ||
| 113 |                 if ($col) { | ||
| 114 | return isset(self::$cols[$col][2]['sort']) ? | ||
| 115 | self::$cols[$col][2]['sort'] : | ||
| 116 | self::$cols[$col][1]; | ||
| 117 | } | ||
| 118 | return self::$t['order']['col']; | ||
| 119 | case 'OrderDir': | ||
| 120 | $reset = filter_has_var(INPUT_GET, 'col') ? 'asc' : null; | ||
| 121 | return | ||
| 122 | in_array(filter_input(INPUT_GET, 'ord'), ['asc', 'desc']) ? | ||
| 123 | filter_input(INPUT_GET, 'ord') : | ||
| 124 | ($reset ?: self::$t['order']['dir']); | ||
| 125 | case 'Page': | ||
| 126 | return | ||
| 127 | filter_has_var(INPUT_GET, 'pg') && self::$export == false ? | ||
| 128 | (int)filter_input(INPUT_GET, 'pg', FILTER_SANITIZE_NUMBER_INT) : | ||
| 129 | self::$t['page']; | ||
| 130 | case 'Export': | ||
| 131 | $exp = filter_input(INPUT_GET, 'export', FILTER_SANITIZE_STRING); | ||
| 132 |                 return in_array($exp, self::config('SAVES')) ? $exp : false; | ||
| 133 | } | ||
| 136 | 
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.