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