Completed
Push — master ( d54d1c...bce55f )
by Filippo
06:32 queued 03:36
created
src/EoC/CLI/Command/QueryCommand.php 1 patch
Braces   +70 added lines, -52 removed lines patch added patch discarded remove patch
@@ -188,81 +188,98 @@  discard block
 block discarded – undo
188 188
       $args = $input->getArgument('keys');
189 189
 
190 190
       $keys = [];
191
-      foreach ($args as $key)
192
-        $keys[] = $this->castArg($key, FALSE);
191
+      foreach ($args as $key) {
192
+              $keys[] = $this->castArg($key, FALSE);
193
+      }
194
+    } else {
195
+          $keys = NULL;
193 196
     }
194
-    else
195
-      $keys = NULL;
196 197
 
197 198
     // Sets the options.
198 199
     $opts = new ViewQueryOpts();
199 200
 
200 201
     // Key.
201
-    if ($key = $input->getOption('key'))
202
-      $opts->setKey($this->castArg($key), FALSE);
202
+    if ($key = $input->getOption('key')) {
203
+          $opts->setKey($this->castArg($key), FALSE);
204
+    }
203 205
 
204 206
     // Start key.
205
-    if ($startkey = $input->getOption('startkey'))
206
-      $opts->setStartKey($this->castArg($startkey), FALSE);
207
+    if ($startkey = $input->getOption('startkey')) {
208
+          $opts->setStartKey($this->castArg($startkey), FALSE);
209
+    }
207 210
 
208 211
     // End key.
209
-    if ($endkey = $input->getOption('endkey'))
210
-      $opts->setEndKey($this->castArg($endkey), FALSE);
212
+    if ($endkey = $input->getOption('endkey')) {
213
+          $opts->setEndKey($this->castArg($endkey), FALSE);
214
+    }
211 215
 
212 216
     // Start doc id.
213
-    if ($docId = $input->getOption('startkey-docid'))
214
-      $opts->setStartDocId($docId);
217
+    if ($docId = $input->getOption('startkey-docid')) {
218
+          $opts->setStartDocId($docId);
219
+    }
215 220
 
216 221
     // End doc id.
217
-    if ($docId = $input->getOption('endkey-docid'))
218
-      $opts->setEndDocId($docId);
222
+    if ($docId = $input->getOption('endkey-docid')) {
223
+          $opts->setEndDocId($docId);
224
+    }
219 225
 
220 226
     // Limit.
221 227
     $limit = (int)$input->getOption('limit');
222
-    if ($limit > 0)
223
-      $opts->setLimit($limit);
228
+    if ($limit > 0) {
229
+          $opts->setLimit($limit);
230
+    }
224 231
 
225 232
     // Group results.
226
-    if ($input->getOption('group-results'))
227
-      $opts->groupResults();
233
+    if ($input->getOption('group-results')) {
234
+          $opts->groupResults();
235
+    }
228 236
 
229 237
     // Sets group level.
230 238
     $level = (int)$input->getOption('group-level');
231
-    if ($level > 0)
232
-      $opts->setGroupLevel($level);
239
+    if ($level > 0) {
240
+          $opts->setGroupLevel($level);
241
+    }
233 242
 
234 243
     // Do not reduce.
235
-    if ($input->getOption('do-not-reduce'))
236
-      $opts->doNotReduce();
244
+    if ($input->getOption('do-not-reduce')) {
245
+          $opts->doNotReduce();
246
+    }
237 247
 
238 248
     // Includes docs.
239
-    if ($input->getOption('include-docs'))
240
-      $opts->includeDocs();
249
+    if ($input->getOption('include-docs')) {
250
+          $opts->includeDocs();
251
+    }
241 252
 
242 253
     // Excludes results.
243
-    if ($input->getOption('exclude-results'))
244
-      $opts->excludeResults();
254
+    if ($input->getOption('exclude-results')) {
255
+          $opts->excludeResults();
256
+    }
245 257
 
246 258
     // Excludes endkey.
247
-    if ($input->getOption('exclude-endkey'))
248
-      $opts->excludeEndKey();
259
+    if ($input->getOption('exclude-endkey')) {
260
+          $opts->excludeEndKey();
261
+    }
249 262
 
250 263
     // Reverses order of results.
251
-    if ($input->getOption('reverse-order'))
252
-      $opts->reverseOrderOfResults();
264
+    if ($input->getOption('reverse-order')) {
265
+          $opts->reverseOrderOfResults();
266
+    }
253 267
 
254 268
     // Skips the defined number of documents.
255 269
     $skip = (int)$input->getOption('skip');
256
-    if ($skip > 0)
257
-      $opts->skipDocs($skip);
270
+    if ($skip > 0) {
271
+          $opts->skipDocs($skip);
272
+    }
258 273
 
259 274
     // Includes conflicts.
260
-    if ($input->getOption('include-conflicts'))
261
-      $opts->includeConflicts();
275
+    if ($input->getOption('include-conflicts')) {
276
+          $opts->includeConflicts();
277
+    }
262 278
 
263 279
     // Includes missing keys.
264
-    if ($input->getOption('include-missing-keys'))
265
-      $opts->includeMissingKeys();
280
+    if ($input->getOption('include-missing-keys')) {
281
+          $opts->includeMissingKeys();
282
+    }
266 283
 
267 284
     if ($view == "_temp_view") {
268 285
 
@@ -270,30 +287,31 @@  discard block
 block discarded – undo
270 287
       if ($fileName = $input->getOption('map')) {
271 288
         $map = file_get_contents($fileName);
272 289
 
273
-        if ($fileName = $input->getOption('reduce'))
274
-          $reduce = file_get_contents($fileName);
275
-        else
276
-          $reduce = "";
290
+        if ($fileName = $input->getOption('reduce')) {
291
+                  $reduce = file_get_contents($fileName);
292
+        } else {
293
+                  $reduce = "";
294
+        }
277 295
 
278 296
         $language = $input->getOption('language');
279
-        if (empty($language))
280
-          $language = "php";
297
+        if (empty($language)) {
298
+                  $language = "php";
299
+        }
300
+      } else {
301
+              throw new \InvalidArgumentException("You didn't provided the map function.");
281 302
       }
282
-      else
283
-        throw new \InvalidArgumentException("You didn't provided the map function.");
284 303
 
285 304
       print_r($couch->queryTempView($map, $reduce, $keys, $opts, $language));
286
-    }
287
-    elseif ($view == "_all_docs") {
305
+    } elseif ($view == "_all_docs") {
288 306
       print_r($couch->queryAllDocs($keys, $opts));
289
-    }
290
-    else {
307
+    } else {
291 308
       $names = explode('/', $view, 2);
292 309
 
293
-      if (count($names) == 2)
294
-        var_dump($couch->queryView($names[0], $names[1], $keys, $opts));
295
-      else
296
-        throw new \InvalidArgumentException("You have to specify design-doc/view-name.");
310
+      if (count($names) == 2) {
311
+              var_dump($couch->queryView($names[0], $names[1], $keys, $opts));
312
+      } else {
313
+              throw new \InvalidArgumentException("You have to specify design-doc/view-name.");
314
+      }
297 315
     }
298 316
 
299 317
   }
Please login to merge, or discard this patch.