Completed
Push — device-groups ( 198a39...479001 )
by Tony
07:57 queued 04:52
created
app/Models/DeviceGroup.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
     /**
165 165
      * Extract an array of tables in a pattern
166 166
      *
167
-     * @param $pattern
167
+     * @param string $pattern
168 168
      * @return array
169 169
      */
170 170
     private function getTablesFromPattern($pattern)
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
      * Convert a v1 device group pattern to v2 style
204 204
      *
205 205
      * @param $pattern
206
-     * @return array
206
+     * @return string
207 207
      */
208 208
     private function convertV1Pattern($pattern)
209 209
     {
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
         $related = $this->getRelation('deviceCountRelation')->first();
93 93
 
94 94
         // then return the count directly
95
-        return ($related) ? (int)$related->count : 0;
95
+        return ($related) ? (int) $related->count : 0;
96 96
     }
97 97
 
98 98
     /**
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
         if (starts_with($pattern, '%')) {
192 192
             $pattern = $this->convertV1Pattern($pattern);
193 193
 
194
-            $this->pattern = $pattern;  //TODO: does not save, only updates this instance
194
+            $this->pattern = $pattern; //TODO: does not save, only updates this instance
195 195
         }
196 196
 
197 197
         return $pattern;
Please login to merge, or discard this patch.
Braces   +14 added lines, -7 removed lines patch added patch discarded remove patch
@@ -144,7 +144,8 @@  discard block
 block discarded – undo
144 144
         $query = null;
145 145
         if (count($tables) == 1) {
146 146
             $query = DB::table($tables[0])->select('device_id');
147
-        } else {
147
+        }
148
+        else {
148 149
             $query = DB::table('devices')->select('devices.device_id')->distinct();
149 150
 
150 151
             foreach ($tables as $table) {
@@ -221,14 +222,16 @@  discard block
 block discarded – undo
221 222
             if (starts_with($cur, '%')) {
222 223
                 // table and column
223 224
                 $out .= substr($cur, 1).' ';
224
-            } elseif (substr($cur, -1) == '~') {
225
+            }
226
+            elseif (substr($cur, -1) == '~') {
225 227
                 // like operator
226 228
                 $content = $parts[++$i]; // grab the content so we can format it
227 229
 
228 230
                 if (str_contains($content, '@')) {
229 231
                     // contains wildcard
230 232
                     $content = str_replace('@', '%', $content);
231
-                } else {
233
+                }
234
+                else {
232 235
                     // assume substring
233 236
                     $content = '%'.$content.'%';
234 237
                 }
@@ -240,14 +243,18 @@  discard block
 block discarded – undo
240 243
 
241 244
                 $out .= "LIKE('".$content."') ";
242 245
 
243
-            } elseif ($cur == '&&') {
246
+            }
247
+            elseif ($cur == '&&') {
244 248
                 $out .= 'AND ';
245
-            } elseif ($cur == '||') {
249
+            }
250
+            elseif ($cur == '||') {
246 251
                 $out .= 'OR ';
247
-            } elseif (in_array($cur, $ops)) {
252
+            }
253
+            elseif (in_array($cur, $ops)) {
248 254
                 // passthrough operators
249 255
                 $out .= $cur.' ';
250
-            } else {
256
+            }
257
+            else {
251 258
                 // user supplied input
252 259
                 $out .= "'".trim($cur, '"\'')."' "; // TODO: remove trim, only needed with invalid input
253 260
             }
Please login to merge, or discard this patch.