Passed
Push — master ( af185e...b32849 )
by Plamen
01:30
created
table.php 2 patches
Spacing   +2 added lines, -3 removed lines patch added patch discarded remove patch
@@ -30,8 +30,7 @@  discard block
 block discarded – undo
30 30
     public static function prepare($setOrCheck = false)
31 31
     {
32 32
         //@see  http://php.net/manual/es/function.filter-input.php#77307
33
-        $uri = filter_input(INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_URL) ?:
34
-            filter_var($_SERVER['REQUEST_URI'], FILTER_SANITIZE_URL);
33
+        $uri = filter_input(INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_URL) ?: filter_var($_SERVER['REQUEST_URI'], FILTER_SANITIZE_URL);
35 34
 
36 35
         $extension = pathinfo(strtok($uri, '?'), PATHINFO_EXTENSION);
37 36
 
@@ -83,7 +82,7 @@  discard block
 block discarded – undo
83 82
         self::$t = self::request(self::$export);
84 83
 
85 84
         $order = [self::$t['order']['col'] => self::$t['order']['dir']];
86
-        $offset = (self::$t['page'] - 1) * self::$t['paging'];
85
+        $offset = (self::$t['page'] - 1)*self::$t['paging'];
87 86
         $limit = [$offset, self::$t['paging']];
88 87
         self::$t['q'] = self::query($query, self::$t['filter'], $order, $limit, true);
89 88
 
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.
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 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,7 +83,7 @@  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", "	", $value);
90 88
                 };
91 89
                 header('Content-Type:application/csv');
@@ -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_query.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@
 block discarded – undo
43 43
     private static function queryOrder(&$query, $order)
44 44
     {
45 45
         if (!empty($order)) {
46
-            $arr = array_map(function (&$value, $key) {
46
+            $arr = array_map(function(&$value, $key) {
47 47
                 return $key . ' ' . strtoupper($value);
48 48
             }, $order, array_keys($order));
49 49
             $query .= (' ORDER BY ' . implode(', ', $arr));
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -17,8 +17,7 @@
 block discarded – undo
17 17
         array $order = [],
18 18
         $limit = 0,
19 19
         $useHaving = false
20
-    )
21
-    {
20
+    ) {
22 21
         //Condition: '' | ' (HAVING|WHERE|AND) ' . $cond
23 22
         self::queryConditions($query, $cond, $useHaving);
24 23
 
Please login to merge, or discard this patch.
thead.php 1 patch
Spacing   +4 added lines, -8 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,8 +46,7 @@  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)) {
@@ -85,8 +83,7 @@  discard block
 block discarded – undo
85 83
         if (isset($arg['width'])) { // Width attribute -> style
86 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')) {
@@ -107,8 +104,7 @@  discard block
 block discarded – undo
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
             }
Please login to merge, or discard this patch.
trait_paging.php 1 patch
Spacing   +8 added lines, -10 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;
@@ -46,12 +45,11 @@  discard block
 block discarded – undo
46 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 51
             $html = $direction === '-' ? $add . $html : $html . $add;
54
-            return self::jumps($html, ($multiplier * 10));
52
+            return self::jumps($html, ($multiplier*10));
55 53
         }
56 54
 
57 55
         return $html;
@@ -60,9 +58,9 @@  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 65
             return ($direction . $multiplier);
68 66
         }
Please login to merge, or discard this patch.
trait_request.php 1 patch
Spacing   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -54,8 +54,7 @@  discard block
 block discarded – undo
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.
tfoot.php 1 patch
Spacing   +5 added lines, -7 removed lines patch added patch discarded remove patch
@@ -41,12 +41,11 @@  discard block
 block discarded – undo
41 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'];
@@ -73,8 +72,7 @@  discard block
 block discarded – undo
73 72
             $res = $select($expression, $bindings);
74 73
             //if result is single cell value ($res[0]->value), return the value
75 74
             return (count($res) === 1 && count((array) $res[0]) === 1) ?
76
-                reset($res[0]) :
77
-                $res;
75
+                reset($res[0]) : $res;
78 76
         } else {
79 77
             throw new Exception('ERROR: table::$select is not a closure. ');
80 78
         }
Please login to merge, or discard this patch.