Passed
Push — dev ( e388e4...92a70d )
by Plamen
02:09
created
TraitHelper.php 1 patch
Spacing   +9 added lines, -10 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
 
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
             if ($value === true || (empty($value) && $value != 0)) {
34 34
                 $list[] = $key;
35 35
             } else {
36
-                $list[] = $key.'="'.$value.'"';
36
+                $list[] = $key . '="' . $value . '"';
37 37
             }
38 38
         }
39 39
         return rtrim(implode(' ', $list));
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
             self::$cols = [];
63 63
             self::$t['rows'] = null;
64 64
         } else {
65
-            echo 'Existing table-id used in table::create(): '.$items;
65
+            echo 'Existing table-id used in table::create(): ' . $items;
66 66
         }
67 67
     }
68 68
 
@@ -74,23 +74,22 @@  discard block
 block discarded – undo
74 74
         try {
75 75
             $p = explode('.', $property);
76 76
             $name = array_shift($p);
77
-            if(property_exists(__CLASS__, $name)){
77
+            if (property_exists(__CLASS__, $name)) {
78 78
                 switch (count($p)) {
79 79
                     case 3: return static::$$name[$p[0]][$p[1]][$p[2]] === $value;
80 80
                     case 2: return static::$$name[$p[0]][$p[1]] === $value;
81 81
                     case 1: return $p[0] === '∞' ? //request is to the last one
82
-                        static::$$name[(count(static::$$name) - 1)] === $value : 
83
-                        static::$$name[$p[0]] === $value;
82
+                        static::$$name[(count(static::$$name) - 1)] === $value : static::$$name[$p[0]] === $value;
84 83
                     case 0: return static::$$name === $value;
85 84
                     default:
86 85
                         $oops = implode($p);
87
-                        throw new Exception('Missing value ('.$oops.').');
86
+                        throw new Exception('Missing value (' . $oops . ').');
88 87
                 }
89 88
             } else {
90
-                throw new Exception('Undefined property ('.$name.').');
89
+                throw new Exception('Undefined property (' . $name . ').');
91 90
             }
92 91
         } catch (Exception $e) {
93
-            echo 'Caught exception: ',  $e->getMessage(), "\n";
92
+            echo 'Caught exception: ', $e->getMessage(), "\n";
94 93
         }
95 94
 
96 95
         return false;
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.
TraitRequest.php 1 patch
Spacing   +8 added lines, -11 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'];
@@ -66,8 +65,7 @@  discard block
 block discarded – undo
66 65
     {
67 66
         $reset = filter_has_var(INPUT_GET, 'col') ? 'asc' : null;
68 67
         return in_array(filter_input(INPUT_GET, 'ord'), ['asc', 'desc']) ?
69
-            filter_input(INPUT_GET, 'ord') :
70
-            ($reset ?: self::$t['order']['dir']);
68
+            filter_input(INPUT_GET, 'ord') : ($reset ?: self::$t['order']['dir']);
71 69
     }
72 70
 
73 71
     private static function setExport()
@@ -80,7 +78,6 @@  discard block
 block discarded – undo
80 78
     private static function page()
81 79
     {
82 80
         return filter_has_var(INPUT_GET, 'pg') && self::$export == false ?
83
-            (int) filter_input(INPUT_GET, 'pg', FILTER_SANITIZE_NUMBER_INT) :
84
-            self::$t['page'];
81
+            (int) filter_input(INPUT_GET, 'pg', FILTER_SANITIZE_NUMBER_INT) : self::$t['page'];
85 82
     }
86 83
 }
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,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.