Passed
Push — master ( 472f35...abfabd )
by Plamen
01:26
created
table_getter.php 1 patch
Spacing   +14 added lines, -23 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'];
@@ -304,9 +296,8 @@  discard block
 block discarded – undo
304 296
             $select = static::$select;
305 297
             $res = $select($expression, $bindings);
306 298
             //if result is single cell value ($res[0]->value), return the value
307
-            return (count($res) === 1 && count((array) $res[0]) === 1) ?
308
-                    reset($res[0]) :
309
-                    $res;
299
+            return (count($res) === 1 && count((array)$res[0]) === 1) ?
300
+                    reset($res[0]) : $res;
310 301
         } else {
311 302
             throw new Exception('ERROR: table::$select is not a closure. ');
312 303
         }
Please login to merge, or discard this patch.