Passed
Push — master ( 33a4da...5055ab )
by
unknown
03:44
created
src/FrontQL/Adapter/Select/SelectPayload.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -38,21 +38,21 @@  discard block
 block discarded – undo
38 38
     public function getColumns()
39 39
     {
40 40
         // Se nenhuma coluna foi definida todas serão retornadas
41
-        if(!isset($this->payload['columns']) || !is_array($this->payload['columns']))
41
+        if (!isset($this->payload['columns']) || !is_array($this->payload['columns']))
42 42
             return ['*'];
43 43
 
44 44
         $regex = '/^[a-zA-Z_][a-zA-Z0-9_]*$/';
45 45
         $columns = array();
46 46
 
47
-        foreach ($this->payload['columns'] as $column){
47
+        foreach ($this->payload['columns'] as $column) {
48 48
             // Valida o nome da coluna
49
-            if(!is_string($column) || !preg_match($regex, $column))
49
+            if (!is_string($column) || !preg_match($regex, $column))
50 50
                 throw new InvalidColumnNameException();
51 51
 
52 52
             $columns[] = $column;
53 53
         }
54 54
 
55
-        if(count($columns) == 0)
55
+        if (count($columns) == 0)
56 56
             return ['*'];
57 57
 
58 58
         return $columns;
@@ -65,10 +65,10 @@  discard block
 block discarded – undo
65 65
      */
66 66
     public function getLimit()
67 67
     {
68
-        if(!isset($this->payload['limit']))
68
+        if (!isset($this->payload['limit']))
69 69
             return null;
70 70
 
71
-        if(!is_int($this->payload['limit']))
71
+        if (!is_int($this->payload['limit']))
72 72
             return null;
73 73
 
74 74
         return $this->payload['limit'];
@@ -81,10 +81,10 @@  discard block
 block discarded – undo
81 81
      */
82 82
     public function getOffset()
83 83
     {
84
-        if(!isset($this->payload['offset']))
84
+        if (!isset($this->payload['offset']))
85 85
             return null;
86 86
 
87
-        if(!is_int($this->payload['offset']))
87
+        if (!is_int($this->payload['offset']))
88 88
             return null;
89 89
 
90 90
         return $this->payload['offset'];
@@ -99,12 +99,12 @@  discard block
 block discarded – undo
99 99
     {
100 100
         $allowed = ['ASC', 'DESC'];
101 101
 
102
-        if(!isset($this->payload['order']) || !is_array($this->payload['order']))
102
+        if (!isset($this->payload['order']) || !is_array($this->payload['order']))
103 103
             return '';
104 104
 
105 105
         $orders = array();
106 106
 
107
-        foreach ($this->payload['order'] as $order){
107
+        foreach ($this->payload['order'] as $order) {
108 108
             $columns  = implode(', ', $order[0]);
109 109
             $command  = in_array($order[1], $allowed) ? $order[1] : 'ASC';
110 110
             $orders[] = "{$columns}, {$command}";
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
      */
121 121
     public function getWhere()
122 122
     {
123
-        if(!is_array($this->payload['where']))
123
+        if (!is_array($this->payload['where']))
124 124
             return [];
125 125
 
126 126
         $adapter = new WhereAdapter();
Please login to merge, or discard this patch.
Braces   +27 added lines, -18 removed lines patch added patch discarded remove patch
@@ -38,22 +38,25 @@  discard block
 block discarded – undo
38 38
     public function getColumns()
39 39
     {
40 40
         // Se nenhuma coluna foi definida todas serão retornadas
41
-        if(!isset($this->payload['columns']) || !is_array($this->payload['columns']))
42
-            return ['*'];
41
+        if(!isset($this->payload['columns']) || !is_array($this->payload['columns'])) {
42
+                    return ['*'];
43
+        }
43 44
 
44 45
         $regex = '/^[a-zA-Z_][a-zA-Z0-9_]*$/';
45 46
         $columns = array();
46 47
 
47 48
         foreach ($this->payload['columns'] as $column){
48 49
             // Valida o nome da coluna
49
-            if(!is_string($column) || !preg_match($regex, $column))
50
-                throw new InvalidColumnNameException();
50
+            if(!is_string($column) || !preg_match($regex, $column)) {
51
+                            throw new InvalidColumnNameException();
52
+            }
51 53
 
52 54
             $columns[] = $column;
53 55
         }
54 56
 
55
-        if(count($columns) == 0)
56
-            return ['*'];
57
+        if(count($columns) == 0) {
58
+                    return ['*'];
59
+        }
57 60
 
58 61
         return $columns;
59 62
     }
@@ -65,11 +68,13 @@  discard block
 block discarded – undo
65 68
      */
66 69
     public function getLimit()
67 70
     {
68
-        if(!isset($this->payload['limit']))
69
-            return null;
71
+        if(!isset($this->payload['limit'])) {
72
+                    return null;
73
+        }
70 74
 
71
-        if(!is_int($this->payload['limit']))
72
-            return null;
75
+        if(!is_int($this->payload['limit'])) {
76
+                    return null;
77
+        }
73 78
 
74 79
         return $this->payload['limit'];
75 80
     }
@@ -81,11 +86,13 @@  discard block
 block discarded – undo
81 86
      */
82 87
     public function getOffset()
83 88
     {
84
-        if(!isset($this->payload['offset']))
85
-            return null;
89
+        if(!isset($this->payload['offset'])) {
90
+                    return null;
91
+        }
86 92
 
87
-        if(!is_int($this->payload['offset']))
88
-            return null;
93
+        if(!is_int($this->payload['offset'])) {
94
+                    return null;
95
+        }
89 96
 
90 97
         return $this->payload['offset'];
91 98
     }
@@ -99,8 +106,9 @@  discard block
 block discarded – undo
99 106
     {
100 107
         $allowed = ['ASC', 'DESC'];
101 108
 
102
-        if(!isset($this->payload['order']) || !is_array($this->payload['order']))
103
-            return '';
109
+        if(!isset($this->payload['order']) || !is_array($this->payload['order'])) {
110
+                    return '';
111
+        }
104 112
 
105 113
         $orders = array();
106 114
 
@@ -120,8 +128,9 @@  discard block
 block discarded – undo
120 128
      */
121 129
     public function getWhere()
122 130
     {
123
-        if(!is_array($this->payload['where']))
124
-            return [];
131
+        if(!is_array($this->payload['where'])) {
132
+                    return [];
133
+        }
125 134
 
126 135
         $adapter = new WhereAdapter();
127 136
         $where = $adapter->fromArray($this->payload['where']);
Please login to merge, or discard this patch.