Passed
Push — 8.x-1.x ( 9dcd94...22560c )
by Patrick D
06:37
created
src/QueryAggregate.php 1 patch
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -18,8 +18,7 @@  discard block
 block discarded – undo
18 18
         foreach ($agg['buckets'] as $bucket) {
19 19
           $res = array_merge($res, $this->getResultFromBucket($bucket, $group_field));
20 20
         }
21
-      }
22
-      else {
21
+      } else {
23 22
         $res[] = [$group_field => $agg['value']];
24 23
       }
25 24
     }
@@ -91,8 +90,7 @@  discard block
 block discarded – undo
91 90
         $group_by[$group['field']]['terms']['field'] = $group['field'];
92 91
         if ($prev) {
93 92
           $group_by[$group['field']]['aggs'] = $prev;
94
-        }
95
-        elseif (!empty($aggregates)) {
93
+        } elseif (!empty($aggregates)) {
96 94
           $group_by[$group['field']]['aggs'] = $aggregates;
97 95
           
98 96
           // Sort by aggregate values
@@ -119,8 +117,7 @@  discard block
 block discarded – undo
119 117
         $prev = $group_by;
120 118
       }
121 119
       $params['body']['aggs'] = $group_by;
122
-    }
123
-    elseif (!empty($aggregates)) {
120
+    } elseif (!empty($aggregates)) {
124 121
       // Aggregate without grouping. Will only ever produce one result since it's aggregating on the whole dataset.
125 122
       $params['body']['aggs'] = $aggregates;
126 123
     }
Please login to merge, or discard this patch.
src/Query.php 3 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -260,19 +260,19 @@
 block discarded – undo
260 260
       }
261 261
       elseif ($operator == "ENDS_WITH" && $conjunction == "AND") {
262 262
         //TODO: WARNING THIS IS EXPENSIVE
263
-        $bool['filter'][] = ['wildcard' => [$field => '*'.$value]];
263
+        $bool['filter'][] = ['wildcard' => [$field => '*' . $value]];
264 264
       }
265 265
       elseif ($operator == "ENDS_WITH" && $conjunction == "OR") {
266 266
         //TODO: WARNING THIS IS EXPENSIVE
267
-        $bool['should'][] = ['wildcard' => [$field => '*'.$value]];
267
+        $bool['should'][] = ['wildcard' => [$field => '*' . $value]];
268 268
       }
269 269
       elseif ($operator == "CONTAINS" && $conjunction == "AND") {
270 270
         //TODO: WARNING THIS IS EXPENSIVE
271
-        $bool['filter'][] = ['wildcard' => [$field => '*'.$value.'*']];
271
+        $bool['filter'][] = ['wildcard' => [$field => '*' . $value . '*']];
272 272
       }
273 273
       elseif ($operator == "CONTAINS" && $conjunction == "OR") {
274 274
         //TODO: WARNING THIS IS EXPENSIVE
275
-        $bool['should'][] = ['wildcard' => [$field => '*'.$value.'*']];
275
+        $bool['should'][] = ['wildcard' => [$field => '*' . $value . '*']];
276 276
       }
277 277
     }
278 278
 
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -125,8 +125,8 @@
 block discarded – undo
125 125
 
126 126
     // For regular (non-count) queries    
127 127
     if (!$this->count) {
128
-       // Don't include source
129
-       $params['body']['_source'] = $this->includeSource();
128
+        // Don't include source
129
+        $params['body']['_source'] = $this->includeSource();
130 130
     }
131 131
 
132 132
     // Top-level condition
Please login to merge, or discard this patch.
Braces   +31 added lines, -62 removed lines patch added patch discarded remove patch
@@ -79,8 +79,7 @@  discard block
 block discarded – undo
79 79
 
80 80
     if ($this->count) {
81 81
       return $result['count'];
82
-    }
83
-    else {
82
+    } else {
84 83
       // TODO: support for revisions? See https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Entity%21Query%21QueryInterface.php/function/QueryInterface%3A%3Aexecute/8.2.x
85 84
       $results = array();
86 85
       foreach ($result['hits']['hits'] as $hit) {
@@ -94,8 +93,7 @@  discard block
 block discarded – undo
94 93
     $params = $this->buildRequest();
95 94
     if ($this->count) {
96 95
       $result = $this->client->count($params);
97
-    }
98
-    else {
96
+    } else {
99 97
       $result = $this->client->search($params);
100 98
     }
101 99
     
@@ -176,104 +174,75 @@  discard block
 block discarded – undo
176 174
 
177 175
       if (is_object($field) && $conjunction == "AND") {
178 176
         $bool['filter'][] = ['bool' => $this->getElasticFilterItem($field)];
179
-      }
180
-      elseif (is_object($field) && $conjunction == "AND") {
177
+      } elseif (is_object($field) && $conjunction == "AND") {
181 178
         $bool['should'][] = ['bool' => $this->getElasticFilterItem($field)];
182
-      }
183
-      elseif ($operator == "=" && $conjunction == "AND") {
179
+      } elseif ($operator == "=" && $conjunction == "AND") {
184 180
         $bool['filter'][] = ['term' => [$field => $value]];
185
-      }
186
-      elseif ($operator == "=" && $conjunction == "OR") {
181
+      } elseif ($operator == "=" && $conjunction == "OR") {
187 182
         $bool['should'][] = ['term' => [$field => $value]];
188
-      }
189
-      elseif (($operator == "<>" || $operator == "!=") && $conjunction == "AND") {
183
+      } elseif (($operator == "<>" || $operator == "!=") && $conjunction == "AND") {
190 184
         $bool['must_not'][] = ['term' => [$field => $value]];
191
-      }
192
-      elseif (($operator == "<>" || $operator == "!=") && $conjunction == "OR") {
185
+      } elseif (($operator == "<>" || $operator == "!=") && $conjunction == "OR") {
193 186
         $bool['should'][] = ['bool' => ['must_not' => ['term' => [$field => $value]]]];
194
-      }
195
-      elseif ($operator == "IN" && $conjunction == "AND") {
187
+      } elseif ($operator == "IN" && $conjunction == "AND") {
196 188
         $bool['filter'][] = ['terms' => [$field => $value]];
197
-      }
198
-      elseif ($operator == "IN" && $conjunction == "OR") {
189
+      } elseif ($operator == "IN" && $conjunction == "OR") {
199 190
         $bool['should'][] = ['terms' => [$field => $value]];
200
-      }
201
-      elseif ($operator == "NOT IN" && $conjunction == "AND") {
191
+      } elseif ($operator == "NOT IN" && $conjunction == "AND") {
202 192
         $bool['must_not'][] = ['terms' => [$field => $value]];
203
-      }
204
-      elseif ($operator == "NOT IN" && $conjunction == "OR") {
193
+      } elseif ($operator == "NOT IN" && $conjunction == "OR") {
205 194
         $bool['should'][] = ['bool' => ['must_not' => ['terms' => [$field => $value]]]];
206
-      }
207
-      elseif ($operator == "IS NULL" && $conjunction == "AND") {
195
+      } elseif ($operator == "IS NULL" && $conjunction == "AND") {
208 196
         $bool['must_not'][] = ['exists' => ['field' => $field]];
209
-      }
210
-      elseif ($operator == "IS NULL" && $conjunction == "OR") {
197
+      } elseif ($operator == "IS NULL" && $conjunction == "OR") {
211 198
         $bool['should'][] = ['bool' => ['must_not' => ['exists' => ['field' => $field]]]];
212
-      }
213
-      elseif ($operator == "IS NOT NULL" && $conjunction == "AND") {
199
+      } elseif ($operator == "IS NOT NULL" && $conjunction == "AND") {
214 200
         $bool['filter'][] = ['exists' => ['field' => $field]];
215
-      }
216
-      elseif ($operator == "IS NOT NULL" && $conjunction == "OR") {
201
+      } elseif ($operator == "IS NOT NULL" && $conjunction == "OR") {
217 202
         $bool['should'][] = ['exists' => ['field' => $field]];
218
-      }
219
-      elseif ($operator == ">" && $conjunction == "AND") {
203
+      } elseif ($operator == ">" && $conjunction == "AND") {
220 204
         $bool['filter'][] = ['range' => [$field => ['gt' => $value]]];
221
-      }
222
-      elseif ($operator == ">" && $conjunction == "OR") {
205
+      } elseif ($operator == ">" && $conjunction == "OR") {
223 206
         $bool['should'][] = ['range' => [$field => ['gt' => $value]]];
224
-      }
225
-      elseif ($operator == ">=" && $conjunction == "AND") {
207
+      } elseif ($operator == ">=" && $conjunction == "AND") {
226 208
         $bool['filter'][] = ['range' => [$field => ['gte' => $value]]];
227
-      }
228
-      elseif ($operator == ">=" && $conjunction == "OR") {
209
+      } elseif ($operator == ">=" && $conjunction == "OR") {
229 210
         $bool['should'][] = ['range' => [$field => ['gte' => $value]]];
230
-      }
231
-      elseif ($operator == "<" && $conjunction == "AND") {
211
+      } elseif ($operator == "<" && $conjunction == "AND") {
232 212
         $bool['filter'][] = ['range' => [$field => ['lt' => $value]]];
233
-      }
234
-      elseif ($operator == "<" && $conjunction == "OR") {
213
+      } elseif ($operator == "<" && $conjunction == "OR") {
235 214
         $bool['should'][] = ['range' => [$field => ['lt' => $value]]];
236
-      }
237
-      elseif ($operator == "<=" && $conjunction == "AND") {
215
+      } elseif ($operator == "<=" && $conjunction == "AND") {
238 216
         $bool['filter'][] = ['range' => [$field => ['lte' => $value]]];
239
-      }
240
-      elseif ($operator == "<=" && $conjunction == "OR") {
217
+      } elseif ($operator == "<=" && $conjunction == "OR") {
241 218
         $bool['should'][] = ['range' => [$field => ['lte' => $value]]];
242
-      }
243
-      elseif ($operator == "BETWEEN") {
219
+      } elseif ($operator == "BETWEEN") {
244 220
         natsort($value);
245 221
         if ($conjunction == "AND") {
246 222
           $bool['filter'][] = ['range' => [$field => [
247 223
             'gt' => $value[0],
248 224
             'lt' => $value[1],
249 225
           ]]];
250
-        }
251
-        elseif ($conjunction == "OR") {
226
+        } elseif ($conjunction == "OR") {
252 227
           $bool['should'][] = ['range' => [$field => [
253 228
             'gt' => $value[0],
254 229
             'lt' => $value[1],
255 230
           ]]];
256 231
         }
257
-      }
258
-      elseif ($operator == "STARTS_WITH" && $conjunction == "AND") {
232
+      } elseif ($operator == "STARTS_WITH" && $conjunction == "AND") {
259 233
         $bool['filter'][] = ['prefix' => [$field => $value]];
260
-      }
261
-      elseif ($operator == "STARTS_WITH" && $conjunction == "OR") {
234
+      } elseif ($operator == "STARTS_WITH" && $conjunction == "OR") {
262 235
         $bool['should'][] = ['prefix' => [$field => $value]];
263
-      }
264
-      elseif ($operator == "ENDS_WITH" && $conjunction == "AND") {
236
+      } elseif ($operator == "ENDS_WITH" && $conjunction == "AND") {
265 237
         //TODO: WARNING THIS IS EXPENSIVE
266 238
         $bool['filter'][] = ['wildcard' => [$field => '*'.$value]];
267
-      }
268
-      elseif ($operator == "ENDS_WITH" && $conjunction == "OR") {
239
+      } elseif ($operator == "ENDS_WITH" && $conjunction == "OR") {
269 240
         //TODO: WARNING THIS IS EXPENSIVE
270 241
         $bool['should'][] = ['wildcard' => [$field => '*'.$value]];
271
-      }
272
-      elseif ($operator == "CONTAINS" && $conjunction == "AND") {
242
+      } elseif ($operator == "CONTAINS" && $conjunction == "AND") {
273 243
         //TODO: WARNING THIS IS EXPENSIVE
274 244
         $bool['filter'][] = ['wildcard' => [$field => '*'.$value.'*']];
275
-      }
276
-      elseif ($operator == "CONTAINS" && $conjunction == "OR") {
245
+      } elseif ($operator == "CONTAINS" && $conjunction == "OR") {
277 246
         //TODO: WARNING THIS IS EXPENSIVE
278 247
         $bool['should'][] = ['wildcard' => [$field => '*'.$value.'*']];
279 248
       }
Please login to merge, or discard this patch.
src/Elastic.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
  */
13 13
 class Elastic {
14 14
 
15
-  public static function client($config =[]) {
15
+  public static function client($config = []) {
16 16
     static $client; 
17 17
     if (!empty($client)) {
18 18
       return $client;
Please login to merge, or discard this patch.