Passed
Branchmaster (334046)
by Plamen
01:29
created
trait_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.php 1 patch
Spacing   +2 added lines, -3 removed lines patch added patch discarded remove patch
@@ -25,8 +25,7 @@  discard block
 block discarded – undo
25 25
     public static function prepare($setOrCheck = false)
26 26
     {
27 27
         //@see  http://php.net/manual/es/function.filter-input.php#77307
28
-        $uri = filter_input(INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_URL) ?:
29
-                filter_var($_SERVER['REQUEST_URI'], FILTER_SANITIZE_URL);
28
+        $uri = filter_input(INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_URL) ?: filter_var($_SERVER['REQUEST_URI'], FILTER_SANITIZE_URL);
30 29
 
31 30
         $extension = pathinfo(strtok($uri, '?'), PATHINFO_EXTENSION);
32 31
 
@@ -79,7 +78,7 @@  discard block
 block discarded – undo
79 78
 
80 79
         $filter = self::requestFilter();
81 80
         $order = [self::$t['order']['col'] => self::$t['order']['dir']];
82
-        $offset = (self::$t['page'] - 1) * self::$t['paging'];
81
+        $offset = (self::$t['page'] - 1)*self::$t['paging'];
83 82
         $limit = [$offset, self::$t['paging']];
84 83
         self::$t['q'] = self::q($q, $filter, $order, $limit, true);
85 84
 
Please login to merge, or discard this patch.
trait_tfoot_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.
tfoot.php 1 patch
Spacing   +8 added lines, -10 removed lines patch added patch discarded remove patch
@@ -21,14 +21,13 @@  discard block
 block discarded – undo
21 21
                 $q = 'SELECT COUNT(*) FROM (' . self::$t['qAll'] . ') AS dt';
22 22
                 self::$t['rows'] = self::select($q);
23 23
             }
24
-            self::$t['pages'] = ceil(self::$t['rows'] / self::$t['paging']);
24
+            self::$t['pages'] = ceil(self::$t['rows']/self::$t['paging']);
25 25
 
26 26
             $v = [];
27 27
 
28
-            $v['from'] = ($pageNo - 1) * self::$t['paging'] + 1;
29
-            $v['upto'] = ($pageNo * self::$t['paging'] < self::$t['rows']) ?
30
-                    $pageNo * self::$t['paging'] :
31
-                    self::$t['rows'];
28
+            $v['from'] = ($pageNo - 1)*self::$t['paging'] + 1;
29
+            $v['upto'] = ($pageNo*self::$t['paging'] < self::$t['rows']) ?
30
+                    $pageNo*self::$t['paging'] : self::$t['rows'];
32 31
 
33 32
             $v["total"] = self::$t['rows'];
34 33
             $v["items"] = self::$t['items'];
@@ -57,8 +56,8 @@  discard block
 block discarded – undo
57 56
             $ftr = self::jsonTfoot()[0][0];
58 57
             $trs .= '<tr><td' . self::attributes($ftr[1]) . '>'
59 58
                     . $ftr[0] . '</td></tr>';
60
-        } else if(count(self::$errors)>0) {
61
-            $trs .= '<tr><td colspan="'.count(self::$cols).'">' . 
59
+        } else if (count(self::$errors) > 0) {
60
+            $trs .= '<tr><td colspan="' . count(self::$cols) . '">' . 
62 61
                     self::err() . '</td></tr>';
63 62
         }
64 63
         return $trs;
@@ -70,9 +69,8 @@  discard block
 block discarded – undo
70 69
             $select = static::$select;
71 70
             $res = $select($expression, $bindings);
72 71
             //if result is single cell value ($res[0]->value), return the value
73
-            return (count($res) === 1 && count((array) $res[0]) === 1) ?
74
-                    reset($res[0]) :
75
-                    $res;
72
+            return (count($res) === 1 && count((array)$res[0]) === 1) ?
73
+                    reset($res[0]) : $res;
76 74
         } else {
77 75
             throw new Exception('ERROR: table::$select is not a closure. ');
78 76
         }
Please login to merge, or discard this patch.
thead.php 1 patch
Spacing   +4 added lines, -7 removed lines patch added patch discarded remove patch
@@ -46,8 +46,7 @@  discard block
 block discarded – undo
46 46
     private static function tagAttributes($tag, $items)
47 47
     {
48 48
         $attr = $tag === 'div' ?
49
-                ['id' => $items . '-list', 'class' => 'table'] :
50
-                ['id' => $items . '-table', 'data-table' => 'js'];
49
+                ['id' => $items . '-list', 'class' => 'table'] : ['id' => $items . '-table', 'data-table' => 'js'];
51 50
         if (array_key_exists($tag, self::$attributes)) {
52 51
             $attr += self::$attributes[$tag];
53 52
         }
@@ -82,8 +81,7 @@  discard block
 block discarded – undo
82 81
         if (isset($arg['width'])) { // Width attribute -> style
83 82
             $width = 'width:' . $arg['width'] . ';';
84 83
             $arg['style'] = isset($arg['style']) ?
85
-                    $width . $arg['style'] :
86
-                    $width;
84
+                    $width . $arg['style'] : $width;
87 85
         }
88 86
 
89 87
         if (($del = isset($arg['type']) && $arg['type'] == 'delete')) {
@@ -92,7 +90,7 @@  discard block
 block discarded – undo
92 90
             $sort = isset($arg['sort']) ? $arg['sort'] : $col;
93 91
         }
94 92
 
95
-        return array_diff_key((array) $arg, ['sort', 'type', 'width']);
93
+        return array_diff_key((array)$arg, ['sort', 'type', 'width']);
96 94
     }
97 95
 
98 96
     private static function th($i, $attr, $sort, $del, $lbl)
@@ -104,8 +102,7 @@  discard block
 block discarded – undo
104 102
         if (!$del) {
105 103
             if ($sort == self::$t['order']['col']) {
106 104
                 $span = self::$t['order']['dir'] === 'desc' ?
107
-                        self::config('UTF8_DESC_SYMBOL') :
108
-                        self::config('UTF8_ASC_SYMBOL');
105
+                        self::config('UTF8_DESC_SYMBOL') : self::config('UTF8_ASC_SYMBOL');
109 106
             } else {
110 107
                 $span = "";
111 108
             }
Please login to merge, or discard this patch.
tbody.php 1 patch
Spacing   +4 added lines, -7 removed lines patch added patch discarded remove patch
@@ -48,16 +48,14 @@  discard block
 block discarded – undo
48 48
         $rows = [$header];
49 49
 
50 50
         $data = self::$exportDataAsDisplayed ?
51
-                self::$data :
52
-                self::select(self::$t['q']);
51
+                self::$data : self::select(self::$t['q']);
53 52
 
54 53
         if (count($data) > 0) {
55 54
             foreach ($data as $row) {
56 55
                 $cells = [];
57
-                foreach($columns as $column){
56
+                foreach ($columns as $column) {
58 57
                     $cells[] = is_array($row[$column]) ? 
59
-                                $row[$column][0] :
60
-                                $row[$column];
58
+                                $row[$column][0] : $row[$column];
61 59
                 }
62 60
                 $rows[] = $cells;
63 61
             }
@@ -95,8 +93,7 @@  discard block
 block discarded – undo
95 93
                 if (($output = fopen('php://output', 'w'))) {
96 94
                     foreach ($eData as $v) {
97 95
                         self::$export === 'CSV' ?
98
-                                        fputcsv($output, $v) :
99
-                                        fputs($output, implode("\t", array_map($escape, $v)) . "\r\n");
96
+                                        fputcsv($output, $v) : fputs($output, implode("\t", array_map($escape, $v)) . "\r\n");
100 97
                     }
101 98
                     fclose($output);
102 99
                 }
Please login to merge, or discard this patch.
trait_tfoot_setter.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@
 block discarded – undo
63 63
     
64 64
     private static function getValid($k, $v = null)
65 65
     {
66
-         if (!array_key_exists($k, self::$config)) {
66
+            if (!array_key_exists($k, self::$config)) {
67 67
                 throw new Exception('Request to undefined value: ' . $k);
68 68
         }
69 69
 
Please login to merge, or discard this patch.
Spacing   +5 added lines, -7 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
             switch (gettype($c)) {
49 49
                 case 'array';
50 50
                     foreach ($c as $k => $v) {
51
-                        self::$config[$k] = self::getValid((string) $k, $v);
51
+                        self::$config[$k] = self::getValid((string)$k, $v);
52 52
                     }
53 53
                     break;
54 54
                 case 'string':
@@ -88,8 +88,7 @@  discard block
 block discarded – undo
88 88
     {
89 89
         //Condition: '' | '(HAVING|WHERE|AND) ' . $cond
90 90
         $c = !empty($cond) && !strpos($q, ($cl = !$h ? 'WHERE' : 'HAVING')) ?
91
-                (' ' . (!strpos($q, $cl) ? $cl : ' AND ') . ' ' . $cond ) :
92
-                '';
91
+                (' ' . (!strpos($q, $cl) ? $cl : ' AND ') . ' ' . $cond) : '';
93 92
         //Order: '' | 'ORDER BY ' . array_keys($order)[0] . ' ' . $order[0]
94 93
         $o = !empty($order) ?
95 94
                 ' ORDER BY ' . implode(', ',
@@ -100,8 +99,7 @@  discard block
 block discarded – undo
100 99
                 '';
101 100
         //Limit: '' | ' LIMIT ' . '(20, 40|20)'
102 101
         $l = !empty($limit) ?
103
-                (' LIMIT ' . (is_array($limit) ? implode(', ', $limit) : $limit)) :
104
-                '';
102
+                (' LIMIT ' . (is_array($limit) ? implode(', ', $limit) : $limit)) : '';
105 103
 
106 104
         return $q . $c . $o . $l;
107 105
     }
@@ -124,7 +122,7 @@  discard block
 block discarded – undo
124 122
         $list = [];
125 123
         foreach ($attributes as $key => $value) {
126 124
             if (is_bool($value)) {
127
-                if ((bool) $value) {
125
+                if ((bool)$value) {
128 126
                     $list[] = $key;
129 127
                 }
130 128
             } else if (empty($value) && !is_int($value)) {
@@ -145,7 +143,7 @@  discard block
 block discarded – undo
145 143
         extract($vars);
146 144
         ob_start();
147 145
         require $template;
148
-        return (string) ob_get_clean();
146
+        return (string)ob_get_clean();
149 147
     }
150 148
 
151 149
     /**Makes code radey for the next table
Please login to merge, or discard this patch.