Passed
Branchmaster (90adb0)
by Plamen
01:33
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_request.php 1 patch
Spacing   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -37,8 +37,7 @@  discard block
 block discarded – undo
37 37
     {
38 38
         if (($col = filter_input(INPUT_GET, 'col', FILTER_VALIDATE_INT))) {
39 39
             return isset(self::$cols[$col][2]['sort']) ?
40
-                    self::$cols[$col][2]['sort'] :
41
-                    self::$cols[$col][1];
40
+                    self::$cols[$col][2]['sort'] : self::$cols[$col][1];
42 41
         }
43 42
         return self::$t['order']['col'];
44 43
     }
@@ -47,8 +46,7 @@  discard block
 block discarded – undo
47 46
     {
48 47
         $reset = filter_has_var(INPUT_GET, 'col') ? 'asc' : null;
49 48
         return in_array(filter_input(INPUT_GET, 'ord'), ['asc', 'desc']) ?
50
-                filter_input(INPUT_GET, 'ord') :
51
-                ($reset ?: self::$t['order']['dir']);
49
+                filter_input(INPUT_GET, 'ord') : ($reset ?: self::$t['order']['dir']);
52 50
     }
53 51
 
54 52
     private static function requestExport()
@@ -60,7 +58,6 @@  discard block
 block discarded – undo
60 58
     private static function requestPage()
61 59
     {
62 60
         return filter_has_var(INPUT_GET, 'pg') && self::$export == false ?
63
-                (int) filter_input(INPUT_GET, 'pg', FILTER_SANITIZE_NUMBER_INT) :
64
-                self::$t['page'];
61
+                (int)filter_input(INPUT_GET, 'pg', FILTER_SANITIZE_NUMBER_INT) : self::$t['page'];
65 62
     }
66 63
 }
Please login to merge, or discard this patch.
table_setter.php 1 patch
Spacing   +3 added lines, -3 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 filterValues(&$f, &$opts = [])
Please login to merge, or discard this patch.
table_footer_paging.php 1 patch
Spacing   +8 added lines, -10 removed lines patch added patch discarded remove patch
@@ -14,13 +14,12 @@  discard block
 block discarded – undo
14 14
 
15 15
             $limit = 10;
16 16
 
17
-            $v['start'] = $v['page'] > ($limit / 2) ?
18
-                    ($v['page'] - $limit / 2) :
19
-                    1;
17
+            $v['start'] = $v['page'] > ($limit/2) ?
18
+                    ($v['page'] - $limit/2) : 1;
20 19
 
21
-            if ($v['page'] > ($v['pages'] - ($limit / 2))) {
20
+            if ($v['page'] > ($v['pages'] - ($limit/2))) {
22 21
                 $v['final'] = $v['pages'];
23
-            } else if ($v['page'] > ($limit / 2)) {
22
+            } else if ($v['page'] > ($limit/2)) {
24 23
                 $v['final'] = $v['start'] + $limit;
25 24
             } else {
26 25
                 $v['final'] = $limit;
@@ -44,12 +43,11 @@  discard block
 block discarded – undo
44 43
         $add = '<li class="jump"><a>' . self::jumps($m, $direction) . '</a></li>';
45 44
 
46 45
         $jump_exists = $direction === '-' ?
47
-                        (self::$t['page'] - $m) > 0 :
48
-                        (self::$t['page'] + $m) <= self::$t['pages'];
46
+                        (self::$t['page'] - $m) > 0 : (self::$t['page'] + $m) <= self::$t['pages'];
49 47
 
50 48
         if ($jump_exists) {
51 49
             $html = $direction === '-' ? $add . $html : $html . $add;
52
-            return self::pagingJumps($html, ($m * 10));
50
+            return self::pagingJumps($html, ($m*10));
53 51
         }
54 52
 
55 53
         return $html;
@@ -58,9 +56,9 @@  discard block
 block discarded – undo
58 56
     private static function jumps($m, $direction)
59 57
     {
60 58
         if ($m >= 1000000) {
61
-            return ($direction . ($m / 1000000) . "M");
59
+            return ($direction . ($m/1000000) . "M");
62 60
         } else if ($m >= 1000) {
63
-            return ($direction . ($m / 1000) . "K");
61
+            return ($direction . ($m/1000) . "K");
64 62
         } else {
65 63
             return ($direction . $m);
66 64
         }
Please login to merge, or discard this patch.