Passed
Branchmaster (c7c38d)
by Plamen
01:28
created
table.php 1 patch
Spacing   +2 added lines, -3 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 
61 61
         $filter = self::requestFilter();
62 62
         $order = [self::$t['order']['col'] => self::$t['order']['dir']];
63
-        $offset = (self::$t['page'] - 1) * self::$t['paging'];
63
+        $offset = (self::$t['page'] - 1)*self::$t['paging'];
64 64
         $limit = [$offset, self::$t['paging']];
65 65
         self::$t['q'] = self::q($q, $filter, $order, $limit, true);
66 66
 
@@ -104,8 +104,7 @@  discard block
 block discarded – undo
104 104
     public static function prepare($setOrCheck = false)
105 105
     {
106 106
         //@see  http://php.net/manual/es/function.filter-input.php#77307
107
-        $uri = filter_input(INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_URL) ?:
108
-                filter_var($_SERVER['REQUEST_URI'], FILTER_SANITIZE_URL);
107
+        $uri = filter_input(INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_URL) ?: filter_var($_SERVER['REQUEST_URI'], FILTER_SANITIZE_URL);
109 108
 
110 109
         $extension = pathinfo(strtok($uri, '?'), PATHINFO_EXTENSION);
111 110
 
Please login to merge, or discard this patch.
table_getter.php 1 patch
Spacing   +16 added lines, -25 removed lines patch added patch discarded remove patch
@@ -32,8 +32,7 @@  discard block
 block discarded – undo
32 32
                 $sortable = !isset($arg['sort']) || $arg['sort'] !== false;
33 33
 
34 34
                 $sort = $sortable ?
35
-                        (isset($arg['sort']) ? $arg['sort'] : $col) :
36
-                        null;
35
+                        (isset($arg['sort']) ? $arg['sort'] : $col) : null;
37 36
 
38 37
                 if (($del = isset($arg['type']) && $arg['type'] == 'delete')) {
39 38
                     $sortable = false;
@@ -47,11 +46,10 @@  discard block
 block discarded – undo
47 46
                 if (isset($arg['width'])) { // Width attribute -> style
48 47
                     $width = 'width:' . $arg['width'] . ';';
49 48
                     $arg['style'] = isset($arg['style']) ?
50
-                            $width . $arg['style'] :
51
-                            $width;
49
+                            $width . $arg['style'] : $width;
52 50
                 }
53 51
 
54
-                $attr = array_diff_key((array) $arg, ['sort', 'type', 'width']);
52
+                $attr = array_diff_key((array)$arg, ['sort', 'type', 'width']);
55 53
 
56 54
                 $th = '<th' . self::attributes($attr) . '>';
57 55
                 if ($sortable) {
@@ -60,8 +58,7 @@  discard block
 block discarded – undo
60 58
                 if (!$del) {
61 59
                     if ($sort == self::$t['order']['col']) {
62 60
                         $span = self::$t['order']['dir'] === 'desc' ?
63
-                                self::config('UTF8_DESC_SYMBOL') :
64
-                                self::config('UTF8_ASC_SYMBOL');
61
+                                self::config('UTF8_DESC_SYMBOL') : self::config('UTF8_ASC_SYMBOL');
65 62
                     } else {
66 63
                         $span = "";
67 64
                     }
@@ -92,8 +89,7 @@  discard block
 block discarded – undo
92 89
     {
93 90
         //Condition: '' | '(HAVING|WHERE|AND) ' . $cond
94 91
         $c = !empty($cond) && !strpos($q, ($cl = !$h ? 'WHERE' : 'HAVING')) ?
95
-                (' ' . (!strpos($q, $cl) ? $cl : ' AND ') . ' ' . $cond ) :
96
-                '';
92
+                (' ' . (!strpos($q, $cl) ? $cl : ' AND ') . ' ' . $cond) : '';
97 93
         //Order: '' | 'ORDER BY ' . array_keys($order)[0] . ' ' . $order[0]
98 94
         $o = !empty($order) ?
99 95
                 ' ORDER BY ' . implode(', ',
@@ -104,8 +100,7 @@  discard block
 block discarded – undo
104 100
                 '';
105 101
         //Limit: '' | ' LIMIT ' . '(20, 40|20)'
106 102
         $l = !empty($limit) ?
107
-                (' LIMIT ' . (is_array($limit) ? implode(', ', $limit) : $limit)) :
108
-                '';
103
+                (' LIMIT ' . (is_array($limit) ? implode(', ', $limit) : $limit)) : '';
109 104
 
110 105
         return $q . $c . $o . $l;
111 106
     }
@@ -113,8 +108,7 @@  discard block
 block discarded – undo
113 108
     protected static function exportData()
114 109
     {
115 110
         $data = self::$exportDataAsDisplayed ?
116
-                self::$data :
117
-                self::select(self::$t['q']);
111
+                self::$data : self::select(self::$t['q']);
118 112
         $fnReplace = [];
119 113
         $fnReplace[':app'] = self::$app;
120 114
         $fnReplace[':items'] = self::$t['items'];
@@ -160,8 +154,7 @@  discard block
 block discarded – undo
160 154
                 if (($output = fopen('php://output', 'w'))) {
161 155
                     foreach ($eData as $v) {
162 156
                         self::$export === 'CSV' ?
163
-                                        fputcsv($output, $v) :
164
-                                        fputs($output, implode("\t", array_map($escape, $v)) . "\r\n");
157
+                                        fputcsv($output, $v) : fputs($output, implode("\t", array_map($escape, $v)) . "\r\n");
165 158
                     }
166 159
                     fclose($output);
167 160
                 }
@@ -203,14 +196,13 @@  discard block
 block discarded – undo
203 196
                 $q = 'SELECT COUNT(*) FROM (' . self::$t['qAll'] . ') AS dt';
204 197
                 self::$t['rows'] = self::select($q);
205 198
             }
206
-            self::$t['pages'] = ceil(self::$t['rows'] / self::$t['paging']);
199
+            self::$t['pages'] = ceil(self::$t['rows']/self::$t['paging']);
207 200
 
208 201
             $v = [];
209 202
 
210
-            $v['from'] = ($pageNo - 1) * self::$t['paging'] + 1;
211
-            $v['upto'] = ($pageNo * self::$t['paging'] < self::$t['rows']) ?
212
-                    $pageNo * self::$t['paging'] :
213
-                    self::$t['rows'];
203
+            $v['from'] = ($pageNo - 1)*self::$t['paging'] + 1;
204
+            $v['upto'] = ($pageNo*self::$t['paging'] < self::$t['rows']) ?
205
+                    $pageNo*self::$t['paging'] : self::$t['rows'];
214 206
 
215 207
             $v["total"] = self::$t['rows'];
216 208
             $v["items"] = self::$t['items'];
@@ -284,8 +276,8 @@  discard block
 block discarded – undo
284 276
                 $ftr = self::jsonGetFooterData()[0][0];
285 277
                 $trs .= '<tr><td' . self::attributes($ftr[1]) . '>'
286 278
                         . $ftr[0] . '</td></tr>';
287
-            } else if(count(self::$errors)>0) {
288
-                $trs .= '<tr><td colspan="'.count(self::$cols).'">' . 
279
+            } else if (count(self::$errors) > 0) {
280
+                $trs .= '<tr><td colspan="' . count(self::$cols) . '">' . 
289 281
                         self::err() . '</td></tr>';
290 282
             }
291 283
         }
@@ -309,9 +301,8 @@  discard block
 block discarded – undo
309 301
             $select = static::$select;
310 302
             $res = $select($expression, $bindings);
311 303
             //if result is single cell value ($res[0]->value), return the value
312
-            return (count($res) === 1 && count((array) $res[0]) === 1) ?
313
-                    reset($res[0]) :
314
-                    $res;
304
+            return (count($res) === 1 && count((array)$res[0]) === 1) ?
305
+                    reset($res[0]) : $res;
315 306
         } else {
316 307
             throw new Exception('ERROR: table::$select is not a closure. ');
317 308
         }
Please login to merge, or discard this patch.
table_setter.php 1 patch
Spacing   +13 added lines, -17 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
             switch (gettype($c)) {
55 55
                 case 'array';
56 56
                     foreach ($c as $k => $v) {
57
-                        self::$config[$k] = $getValid((string) $k, $v);
57
+                        self::$config[$k] = $getValid((string)$k, $v);
58 58
                     }
59 59
                     break;
60 60
                 case 'string':
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
         $list = [];
86 86
         foreach ($attributes as $key => $value) {
87 87
             if (is_bool($value)) {
88
-                if ((bool) $value) {
88
+                if ((bool)$value) {
89 89
                     $list[] = $key;
90 90
                 }
91 91
             } else if (empty($value) && !is_int($value)) {
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
         extract($vars);
107 107
         ob_start();
108 108
         require $template;
109
-        return (string) ob_get_clean();
109
+        return (string)ob_get_clean();
110 110
     }
111 111
 
112 112
     protected static function paging(&$v)
@@ -121,13 +121,12 @@  discard block
 block discarded – undo
121 121
 
122 122
             $limit = 10;
123 123
 
124
-            $v['start'] = $v['page'] > ($limit / 2) ?
125
-                    ($v['page'] - $limit / 2) :
126
-                    1;
124
+            $v['start'] = $v['page'] > ($limit/2) ?
125
+                    ($v['page'] - $limit/2) : 1;
127 126
 
128
-            if ($v['page'] > ($v['pages'] - ($limit / 2))) {
127
+            if ($v['page'] > ($v['pages'] - ($limit/2))) {
129 128
                 $v['final'] = $v['pages'];
130
-            } else if ($v['page'] > ($limit / 2)) {
129
+            } else if ($v['page'] > ($limit/2)) {
131 130
                 $v['final'] = $v['start'] + $limit;
132 131
             } else {
133 132
                 $v['final'] = $limit;
@@ -149,9 +148,9 @@  discard block
 block discarded – undo
149 148
         }
150 149
         $jump2show = function($m) use ($direction) {
151 150
             if ($m >= 1000000) {
152
-                return ($direction . ($m / 1000000) . "M");
151
+                return ($direction . ($m/1000000) . "M");
153 152
             } else if ($m >= 1000) {
154
-                return ($direction . ($m / 1000) . "K");
153
+                return ($direction . ($m/1000) . "K");
155 154
             } else {
156 155
                 return ($direction . $m);
157 156
             }
@@ -168,7 +167,7 @@  discard block
 block discarded – undo
168 167
             $html = $direction === '-' ? $add . $html : $html . $add;
169 168
         }
170 169
 
171
-        return $jump_exists ? self::pagingJumps($html, ($m * 10)) : $html;
170
+        return $jump_exists ? self::pagingJumps($html, ($m*10)) : $html;
172 171
     }
173 172
 
174 173
     protected static function filterValues(&$f, &$opts = [])
@@ -218,8 +217,7 @@  discard block
 block discarded – undo
218 217
     {
219 218
         if (($col = filter_input(INPUT_GET, 'col', FILTER_VALIDATE_INT))) {
220 219
             return isset(self::$cols[$col][2]['sort']) ?
221
-                    self::$cols[$col][2]['sort'] :
222
-                    self::$cols[$col][1];
220
+                    self::$cols[$col][2]['sort'] : self::$cols[$col][1];
223 221
         }
224 222
         return self::$t['order']['col'];
225 223
     }
@@ -228,8 +226,7 @@  discard block
 block discarded – undo
228 226
     {
229 227
         $reset = filter_has_var(INPUT_GET, 'col') ? 'asc' : null;
230 228
         return in_array(filter_input(INPUT_GET, 'ord'), ['asc', 'desc']) ?
231
-                filter_input(INPUT_GET, 'ord') :
232
-                ($reset ?: self::$t['order']['dir']);
229
+                filter_input(INPUT_GET, 'ord') : ($reset ?: self::$t['order']['dir']);
233 230
     }
234 231
 
235 232
     protected static function requestExport()
@@ -241,7 +238,6 @@  discard block
 block discarded – undo
241 238
     protected static function requestPage()
242 239
     {
243 240
         return filter_has_var(INPUT_GET, 'pg') && self::$export == false ?
244
-                (int) filter_input(INPUT_GET, 'pg', FILTER_SANITIZE_NUMBER_INT) :
245
-                self::$t['page'];
241
+                (int)filter_input(INPUT_GET, 'pg', FILTER_SANITIZE_NUMBER_INT) : self::$t['page'];
246 242
     }
247 243
 }
Please login to merge, or discard this patch.