Passed
Push — master ( a30cf1...e5900a )
by Plamen
01:35
created
Tfoot.php 1 patch
Spacing   +12 added lines, -14 removed lines patch added patch discarded remove patch
@@ -17,8 +17,8 @@  discard block
 block discarded – undo
17 17
             $vars = [];
18 18
             self::showingMessageVars($vars);
19 19
             if (self::$exportActive === true) {
20
-                $url = strtok(self::$t['slug'], '?&').'.json?table='.
21
-                    self::$t['items'].'&export=';
20
+                $url = strtok(self::$t['slug'], '?&') . '.json?table=' .
21
+                    self::$t['items'] . '&export=';
22 22
                 $vars['export']['url'] = $url;
23 23
                 $vars['export']['types'] = self::config('SAVES');
24 24
             }
@@ -37,15 +37,14 @@  discard block
 block discarded – undo
37 37
             //Skips total count query
38 38
             self::$t['rows'] = count(self::$data);
39 39
         } else {
40
-            $query = 'SELECT COUNT(*) FROM ('.self::$t['qAll'].') AS dt';
40
+            $query = 'SELECT COUNT(*) FROM (' . self::$t['qAll'] . ') AS dt';
41 41
             self::$t['rows'] = self::select($query);
42 42
         }
43
-        self::$t['pages'] = ceil(self::$t['rows'] / self::$t['paging']);
43
+        self::$t['pages'] = ceil(self::$t['rows']/self::$t['paging']);
44 44
 
45
-        $vars['from'] = ($pageNo - 1) * self::$t['paging'] + 1;
46
-        $vars['upto'] = ($pageNo * self::$t['paging'] < self::$t['rows']) ?
47
-            $pageNo * self::$t['paging'] :
48
-            self::$t['rows'];
45
+        $vars['from'] = ($pageNo - 1)*self::$t['paging'] + 1;
46
+        $vars['upto'] = ($pageNo*self::$t['paging'] < self::$t['rows']) ?
47
+            $pageNo*self::$t['paging'] : self::$t['rows'];
49 48
 
50 49
         $vars["total"] = self::$t['rows'];
51 50
         $vars["items"] = self::$t['items'];
@@ -56,11 +55,11 @@  discard block
 block discarded – undo
56 55
         $trs = '';
57 56
         if (self::$t['rows'] > 0) {
58 57
             $ftr = self::jsonTfoot()[0][0];
59
-            $trs .= '<tr><td'.self::attributes($ftr[1]).'>'
60
-                .$ftr[0].'</td></tr>';
58
+            $trs .= '<tr><td' . self::attributes($ftr[1]) . '>'
59
+                .$ftr[0] . '</td></tr>';
61 60
         } elseif (count(self::$errors) > 0) {
62
-            $trs .= '<tr><td colspan="'.count(self::$cols).'">'.
63
-                self::error().'</td></tr>';
61
+            $trs .= '<tr><td colspan="' . count(self::$cols) . '">' .
62
+                self::error() . '</td></tr>';
64 63
         }
65 64
         return $trs;
66 65
     }
@@ -72,8 +71,7 @@  discard block
 block discarded – undo
72 71
             $res = $select($expression, $bindings);
73 72
             //if result is single cell value ($res[0]->value), return the value
74 73
             return (count($res) === 1 && count((array) $res[0]) === 1) ?
75
-                reset($res[0]) :
76
-                $res;
74
+                reset($res[0]) : $res;
77 75
         } else {
78 76
             throw new Exception('ERROR: table::$select is not a closure. ');
79 77
         }
Please login to merge, or discard this patch.
Thead.php 1 patch
Spacing   +12 added lines, -16 removed lines patch added patch discarded remove patch
@@ -31,8 +31,7 @@  discard block
 block discarded – undo
31 31
 
32 32
     protected static function filterValues(&$filter, &$opts = [])
33 33
     {
34
-        $filter = filter_input(INPUT_GET, 'filter', FILTER_SANITIZE_STRING) ?:
35
-            null;
34
+        $filter = filter_input(INPUT_GET, 'filter', FILTER_SANITIZE_STRING) ?: null;
36 35
 
37 36
         $filterBy = filter_input(INPUT_GET, 'filter-by', FILTER_VALIDATE_INT);
38 37
         foreach (self::$cols as $key => $value) {
@@ -47,15 +46,14 @@  discard block
 block discarded – undo
47 46
     private static function tagAttributes($tag, $items)
48 47
     {
49 48
         $attr = $tag === 'div' ?
50
-            ['id' => $items.'-list', 'class' => 'table'] :
51
-            ['id' => $items.'-table', 'data-table' => 'js',
49
+            ['id' => $items . '-list', 'class' => 'table'] : ['id' => $items . '-table', 'data-table' => 'js',
52 50
             'data-sort-a' => self::config('UTF8_ASC_SYMBOL'),
53 51
             'data-sort-d' => self::config('UTF8_DESC_SYMBOL')];
54 52
         if (array_key_exists($tag, self::$attributes)) {
55 53
             $attr += self::$attributes[$tag];
56 54
         }
57 55
         if (isset(self::$attributes[$tag]['class'])) {
58
-            $attr['class'] .= ' '.self::$attributes[$tag]['class'];
56
+            $attr['class'] .= ' ' . self::$attributes[$tag]['class'];
59 57
         }
60 58
         return self::attributes($attr);
61 59
     }
@@ -83,10 +81,9 @@  discard block
 block discarded – undo
83 81
     private static function thAttributes($col, $arg, &$sort, &$del)
84 82
     {
85 83
         if (isset($arg['width'])) { // Width attribute -> style
86
-            $width = 'width:'.$arg['width'].';';
84
+            $width = 'width:' . $arg['width'] . ';';
87 85
             $arg['style'] = isset($arg['style']) ?
88
-                $width.$arg['style'] :
89
-                $width;
86
+                $width . $arg['style'] : $width;
90 87
         }
91 88
 
92 89
         if (($del = isset($arg['type']) && $arg['type'] == 'delete')) {
@@ -100,23 +97,22 @@  discard block
 block discarded – undo
100 97
 
101 98
     private static function thTag($index, $attr, $sort, $del, $lbl)
102 99
     {
103
-        $tag = '<th'.self::attributes($attr).'>';
100
+        $tag = '<th' . self::attributes($attr) . '>';
104 101
         if ($sort) {
105
-            $tag .= '<a onclick="table.Sort('.$index.',this);">';
102
+            $tag .= '<a onclick="table.Sort(' . $index . ',this);">';
106 103
         }
107 104
         if (!$del) {
108 105
             if ($sort == self::$t['order']['col']) {
109 106
                 $span = self::$t['order']['dir'] === 'desc' ?
110
-                    self::config('UTF8_DESC_SYMBOL') :
111
-                    self::config('UTF8_ASC_SYMBOL');
107
+                    self::config('UTF8_DESC_SYMBOL') : self::config('UTF8_ASC_SYMBOL');
112 108
             } else {
113 109
                 $span = "";
114 110
             }
115
-            $tag .= '<span>'.$span.'</span>'.$lbl;
111
+            $tag .= '<span>' . $span . '</span>' . $lbl;
116 112
         } else {
117
-            $tag .= '<input id="'.self::$t['items'].'CheckDeleteAll"'.
118
-                ' onclick=\"checkAllDeleteCheckboxes(this,'.
119
-                ' \''.self::$t['items'].'\')" type="checkbox"/>';
113
+            $tag .= '<input id="' . self::$t['items'] . 'CheckDeleteAll"' .
114
+                ' onclick=\"checkAllDeleteCheckboxes(this,' .
115
+                ' \'' . self::$t['items'] . '\')" type="checkbox"/>';
120 116
         }
121 117
         if ($sort) {
122 118
             $tag .= '</a>';
Please login to merge, or discard this patch.
Tbody.php 1 patch
Spacing   +10 added lines, -13 removed lines patch added patch discarded remove patch
@@ -31,10 +31,10 @@  discard block
 block discarded – undo
31 31
             if (isset($r[0][1], $r[0][1]['class']) &&
32 32
                 $r[0][1]['class'] === 'no-results'
33 33
             ) {
34
-                $trs .= '<tr><td'.self::attributes($r[0][1]).'>'
35
-                    .$r[0][0].'</td></tr>';
34
+                $trs .= '<tr><td' . self::attributes($r[0][1]) . '>'
35
+                    .$r[0][0] . '</td></tr>';
36 36
             } else {
37
-                $trs .= '<tr><td>'.implode('</td><td>', $r)
37
+                $trs .= '<tr><td>' . implode('</td><td>', $r)
38 38
                     .'</td></tr>';
39 39
             }
40 40
         }
@@ -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 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
             }
@@ -85,18 +83,17 @@  discard block
 block discarded – undo
85 83
         switch (self::$export) {
86 84
             case 'Excel':
87 85
             case 'CSV':
88
-                $escape = function ($value) {
86
+                $escape = function($value) {
89 87
                     return str_replace("\t", "&#9;", $value);
90 88
                 };
91 89
                 header('Content-Type:application/csv');
92
-                header('Content-Disposition:attachment; filename='.
93
-                    $filename.'.csv');
90
+                header('Content-Disposition:attachment; filename=' .
91
+                    $filename . '.csv');
94 92
 
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
                 }
@@ -110,7 +107,7 @@  discard block
 block discarded – undo
110 107
         $fnReplace[':app'] = self::config('APP');
111 108
         $fnReplace[':items'] = self::$t['items'];
112 109
         $format = str_replace(':', '.', '%d.%m.%Y  %H:%i:%s');
113
-        $timeQuery = 'SELECT DATE_FORMAT(Now(), "'.$format.'") AS `now`;';
110
+        $timeQuery = 'SELECT DATE_FORMAT(Now(), "' . $format . '") AS `now`;';
114 111
         $fnReplace[':datetime'] = self::select($timeQuery);
115 112
         return strtr((string) self::config('EXPORT_FILE_NAME'), $fnReplace);
116 113
     }
Please login to merge, or discard this patch.
Table.php 2 patches
Spacing   +6 added lines, -7 removed lines patch added patch discarded remove patch
@@ -36,8 +36,7 @@  discard block
 block discarded – undo
36 36
     public static function prepare($setOrCheck = false)
37 37
     {
38 38
         //@see  http://php.net/manual/es/function.filter-input.php#77307
39
-        $uri = filter_input(INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_URL) ?:
40
-            filter_var($_SERVER['REQUEST_URI'], FILTER_SANITIZE_URL);
39
+        $uri = filter_input(INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_URL) ?: filter_var($_SERVER['REQUEST_URI'], FILTER_SANITIZE_URL);
41 40
 
42 41
         $extension = pathinfo(strtok($uri, '?'), PATHINFO_EXTENSION);
43 42
 
@@ -70,9 +69,9 @@  discard block
 block discarded – undo
70 69
         self::$t['order']['col'] = $orderBy;
71 70
         $dir = strtolower($orderDir);
72 71
         self::$t['order']['dir'] = in_array($dir, ['asc', 'desc']) ?
73
-            $dir : self::error('Invalid orderDir (Asc/Desc): '.$orderDir);
72
+            $dir : self::error('Invalid orderDir (Asc/Desc): ' . $orderDir);
74 73
         self::$t['paging'] = ($num = abs($paging)) > 10 ?
75
-            $num : self::error('Invalid paging (>10): '.$paging);
74
+            $num : self::error('Invalid paging (>10): ' . $paging);
76 75
     }
77 76
 
78 77
     /**
@@ -89,7 +88,7 @@  discard block
 block discarded – undo
89 88
         self::$t = self::request(self::$export);
90 89
 
91 90
         $order = [self::$t['order']['col'] => self::$t['order']['dir']];
92
-        $offset = (self::$t['page'] - 1) * self::$t['paging'];
91
+        $offset = (self::$t['page'] - 1)*self::$t['paging'];
93 92
         $limit = [$offset, self::$t['paging']];
94 93
         self::$t['q'] = self::query($query, self::$t['filter'], $order, $limit, true);
95 94
 
@@ -102,7 +101,7 @@  discard block
 block discarded – undo
102 101
         try {
103 102
             self::$data = self::select($query);
104 103
         } catch (Exception $e) {
105
-            self::error('ERROR: '.$query.'<br />'.$e->getMessage());
104
+            self::error('ERROR: ' . $query . '<br />' . $e->getMessage());
106 105
         }
107 106
     }
108 107
 
@@ -114,7 +113,7 @@  discard block
 block discarded – undo
114 113
             echo parent::load();
115 114
         } else {
116 115
             $tableId = filter_input(INPUT_GET, 'table-id') ?: null;
117
-            if ($tableId === self::$t['items'].'-table') {
116
+            if ($tableId === self::$t['items'] . '-table') {
118 117
                 ob_get_clean();
119 118
                 ob_start("ob_gzhandler");
120 119
                 if (!self::$export) {
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -57,8 +57,7 @@
 block discarded – undo
57 57
         $orderBy,
58 58
         $orderDir = 'asc',
59 59
         $paging = 10
60
-    )
61
-    {
60
+    ) {
62 61
         self::reset((self::$t['items'] = (string) $items));
63 62
         self::prepare(true);
64 63
         self::$t['order']['col'] = $orderBy;
Please login to merge, or discard this patch.
TraitRequest.php 1 patch
Spacing   +8 added lines, -11 removed lines patch added patch discarded remove patch
@@ -29,11 +29,11 @@  discard block
 block discarded – undo
29 29
             } else {
30 30
                 $filterBy = self::$cols[$filterBy][1];
31 31
             }
32
-            $filterBy = 'CONCAT(" ",'.$filterBy.', " ")';
32
+            $filterBy = 'CONCAT(" ",' . $filterBy . ', " ")';
33 33
             if (self::config('FILTER_CASE_SENSITIVE') !== true) {
34
-                $filterBy .= ' COLLATE '.self::config('DB_COLLATION_CI');
34
+                $filterBy .= ' COLLATE ' . self::config('DB_COLLATION_CI');
35 35
             }
36
-            $filter = $filterBy.' LIKE '.'"%'.$filter.'%"';
36
+            $filter = $filterBy . ' LIKE ' . '"%' . $filter . '%"';
37 37
         }
38 38
         return $filter;
39 39
     }
@@ -45,17 +45,16 @@  discard block
 block discarded – undo
45 45
             if (isset($v[2]['sort']) && $v[2]['sort'] === false) {
46 46
                 continue;
47 47
             }
48
-            $all[] = 'IFNULL('.$v[1].', "")';
48
+            $all[] = 'IFNULL(' . $v[1] . ', "")';
49 49
         }
50
-        return 'CONCAT('.implode(',', $all).')';
50
+        return 'CONCAT(' . implode(',', $all) . ')';
51 51
     }
52 52
 
53 53
     private static function orderCol()
54 54
     {
55 55
         if (($col = filter_input(INPUT_GET, 'col', FILTER_VALIDATE_INT))) {
56 56
             return isset(self::$cols[$col][2]['sort']) ?
57
-                self::$cols[$col][2]['sort'] :
58
-                self::$cols[$col][1];
57
+                self::$cols[$col][2]['sort'] : self::$cols[$col][1];
59 58
         }
60 59
         return self::$t['order']['col'];
61 60
     }
@@ -64,8 +63,7 @@  discard block
 block discarded – undo
64 63
     {
65 64
         $reset = filter_has_var(INPUT_GET, 'col') ? 'asc' : null;
66 65
         return in_array(filter_input(INPUT_GET, 'ord'), ['asc', 'desc']) ?
67
-            filter_input(INPUT_GET, 'ord') :
68
-            ($reset ?: self::$t['order']['dir']);
66
+            filter_input(INPUT_GET, 'ord') : ($reset ?: self::$t['order']['dir']);
69 67
     }
70 68
 
71 69
     private static function setExport()
@@ -77,7 +75,6 @@  discard block
 block discarded – undo
77 75
     private static function page()
78 76
     {
79 77
         return filter_has_var(INPUT_GET, 'pg') && self::$export == false ?
80
-            (int) filter_input(INPUT_GET, 'pg', FILTER_SANITIZE_NUMBER_INT) :
81
-            self::$t['page'];
78
+            (int) filter_input(INPUT_GET, 'pg', FILTER_SANITIZE_NUMBER_INT) : self::$t['page'];
82 79
     }
83 80
 }
Please login to merge, or discard this patch.
TraitPaging.php 1 patch
Spacing   +11 added lines, -13 removed lines patch added patch discarded remove patch
@@ -15,13 +15,12 @@  discard block
 block discarded – undo
15 15
 
16 16
             $limit = 10;
17 17
 
18
-            $vars['start'] = $vars['page'] > ($limit / 2) ?
19
-                ($vars['page'] - $limit / 2) :
20
-                1;
18
+            $vars['start'] = $vars['page'] > ($limit/2) ?
19
+                ($vars['page'] - $limit/2) : 1;
21 20
 
22
-            if ($vars['page'] > ($vars['pages'] - ($limit / 2))) {
21
+            if ($vars['page'] > ($vars['pages'] - ($limit/2))) {
23 22
                 $vars['final'] = $vars['pages'];
24
-            } elseif ($vars['page'] > ($limit / 2)) {
23
+            } elseif ($vars['page'] > ($limit/2)) {
25 24
                 $vars['final'] = $vars['start'] + $limit;
26 25
             } else {
27 26
                 $vars['final'] = $limit;
@@ -43,15 +42,14 @@  discard block
 block discarded – undo
43 42
         }
44 43
 
45 44
         $jump = self::jump($multiplier, $direction);
46
-        $add = '<li class="jump"><a>'.$jump.'</a></li>';
45
+        $add = '<li class="jump"><a>' . $jump . '</a></li>';
47 46
 
48 47
         $jumpExists = $direction === '-' ?
49
-            (self::$t['page'] - $multiplier) > 0 :
50
-            (self::$t['page'] + $multiplier) <= self::$t['pages'];
48
+            (self::$t['page'] - $multiplier) > 0 : (self::$t['page'] + $multiplier) <= self::$t['pages'];
51 49
 
52 50
         if ($jumpExists) {
53
-            $html = $direction === '-' ? $add.$html : $html.$add;
54
-            return self::jumps($html, ($multiplier * 10));
51
+            $html = $direction === '-' ? $add . $html : $html . $add;
52
+            return self::jumps($html, ($multiplier*10));
55 53
         }
56 54
 
57 55
         return $html;
@@ -60,11 +58,11 @@  discard block
 block discarded – undo
60 58
     private static function jump($multiplier, $direction)
61 59
     {
62 60
         if ($multiplier >= 1000000) {
63
-            return ($direction.($multiplier / 1000000)."M");
61
+            return ($direction . ($multiplier/1000000) . "M");
64 62
         } elseif ($multiplier >= 1000) {
65
-            return ($direction.($multiplier / 1000)."K");
63
+            return ($direction . ($multiplier/1000) . "K");
66 64
         } else {
67
-            return ($direction.$multiplier);
65
+            return ($direction . $multiplier);
68 66
         }
69 67
     }
70 68
 }
Please login to merge, or discard this patch.
TraitHelper.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -17,8 +17,8 @@  discard block
 block discarded – undo
17 17
 
18 18
     public static function assets($path = "/public/table")
19 19
     {
20
-        return "<script src=\"{$path}/table_helper.js\" defer></script>\n\t".
21
-            "<script src=\"{$path}/table.js\" defer></script>\n\t".
20
+        return "<script src=\"{$path}/table_helper.js\" defer></script>\n\t" .
21
+            "<script src=\"{$path}/table.js\" defer></script>\n\t" .
22 22
             "<link href=\"{$path}/table.css\" rel=\"stylesheet\">\n";
23 23
     }
24 24
 
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
             if ($value === true || (empty($value) && $value != 0)) {
33 33
                 $list[] = $key;
34 34
             } else {
35
-                $list[] = $key.'="'.$value.'"';
35
+                $list[] = $key . '="' . $value . '"';
36 36
             }
37 37
         }
38 38
         return rtrim(implode(' ', $list));
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
             self::$cols = [];
60 60
             self::$t['rows'] = null;
61 61
         } else {
62
-            echo 'Existing table-id used in table::create(): '.$items;
62
+            echo 'Existing table-id used in table::create(): ' . $items;
63 63
         }
64 64
     }
65 65
 }
Please login to merge, or discard this patch.
TraitConfig.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
                     throw new Exception("Invalid value type.");
38 38
             }
39 39
         } catch (Exception $e) {
40
-            self::error('ERROR: '.$e->getMessage());
40
+            self::error('ERROR: ' . $e->getMessage());
41 41
         }
42 42
     }
43 43
 
@@ -47,14 +47,14 @@  discard block
 block discarded – undo
47 47
             self::$errors[] = $message;
48 48
         } else {
49 49
             return empty(self::$errors) ? null :
50
-                '<p class="tbl-err">'.implode('</br>', self::$errors).'</p>';
50
+                '<p class="tbl-err">' . implode('</br>', self::$errors) . '</p>';
51 51
         }
52 52
     }
53 53
 
54 54
     private static function valid($key, $val = null)
55 55
     {
56 56
         if (!array_key_exists($key, self::$config)) {
57
-            throw new Exception('Request to undefined value: '.$key);
57
+            throw new Exception('Request to undefined value: ' . $key);
58 58
         }
59 59
 
60 60
         if ($val !== null) {
Please login to merge, or discard this patch.
TraitQuery.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -36,17 +36,17 @@  discard block
 block discarded – undo
36 36
         if (!empty($cond)) {
37 37
             $clause = !$useHaving ? 'WHERE' : 'HAVING';
38 38
             $clue = !strpos($query, $clause) ? $clause : 'AND';
39
-            $query .= (' '.$clue.' '.$cond);
39
+            $query .= (' ' . $clue . ' ' . $cond);
40 40
         }
41 41
     }
42 42
 
43 43
     private static function queryOrder(&$query, $order)
44 44
     {
45 45
         if (!empty($order)) {
46
-            $arr = array_map(function (&$value, $key) {
47
-                return $key.' '.strtoupper($value);
46
+            $arr = array_map(function(&$value, $key) {
47
+                return $key . ' ' . strtoupper($value);
48 48
             }, $order, array_keys($order));
49
-            $query .= (' ORDER BY '.implode(', ', $arr));
49
+            $query .= (' ORDER BY ' . implode(', ', $arr));
50 50
         }
51 51
     }
52 52
 
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
     {
55 55
         if (!empty($limit)) {
56 56
             $value = (is_array($limit) ? implode(', ', $limit) : $limit);
57
-            $query .= (' LIMIT '.$value);
57
+            $query .= (' LIMIT ' . $value);
58 58
         }
59 59
     }
60 60
 }
Please login to merge, or discard this patch.