@@ -207,81 +207,98 @@ discard block |
||
207 | 207 | $args = $input->getArgument('keys'); |
208 | 208 | |
209 | 209 | $keys = []; |
210 | - foreach ($args as $key) |
|
211 | - $keys[] = $this->castArg($key, FALSE); |
|
210 | + foreach ($args as $key) { |
|
211 | + $keys[] = $this->castArg($key, FALSE); |
|
212 | + } |
|
213 | + } else { |
|
214 | + $keys = NULL; |
|
212 | 215 | } |
213 | - else |
|
214 | - $keys = NULL; |
|
215 | 216 | |
216 | 217 | // Sets the options. |
217 | 218 | $opts = new ViewQueryOpts(); |
218 | 219 | |
219 | 220 | // Key. |
220 | - if ($key = $input->getOption('key')) |
|
221 | - $opts->setKey($this->castArg($key)); |
|
221 | + if ($key = $input->getOption('key')) { |
|
222 | + $opts->setKey($this->castArg($key)); |
|
223 | + } |
|
222 | 224 | |
223 | 225 | // Start key. |
224 | - if ($startkey = $input->getOption('startkey')) |
|
225 | - $opts->setStartKey($this->castArg($startkey)); |
|
226 | + if ($startkey = $input->getOption('startkey')) { |
|
227 | + $opts->setStartKey($this->castArg($startkey)); |
|
228 | + } |
|
226 | 229 | |
227 | 230 | // End key. |
228 | - if ($endkey = $input->getOption('endkey')) |
|
229 | - $opts->setEndKey($this->castArg($endkey)); |
|
231 | + if ($endkey = $input->getOption('endkey')) { |
|
232 | + $opts->setEndKey($this->castArg($endkey)); |
|
233 | + } |
|
230 | 234 | |
231 | 235 | // Start doc id. |
232 | - if ($docId = $input->getOption('startkey-docid')) |
|
233 | - $opts->setStartDocId($docId); |
|
236 | + if ($docId = $input->getOption('startkey-docid')) { |
|
237 | + $opts->setStartDocId($docId); |
|
238 | + } |
|
234 | 239 | |
235 | 240 | // End doc id. |
236 | - if ($docId = $input->getOption('endkey-docid')) |
|
237 | - $opts->setEndDocId($docId); |
|
241 | + if ($docId = $input->getOption('endkey-docid')) { |
|
242 | + $opts->setEndDocId($docId); |
|
243 | + } |
|
238 | 244 | |
239 | 245 | // Limit. |
240 | 246 | $limit = (int)$input->getOption('limit'); |
241 | - if ($limit > 0) |
|
242 | - $opts->setLimit($limit); |
|
247 | + if ($limit > 0) { |
|
248 | + $opts->setLimit($limit); |
|
249 | + } |
|
243 | 250 | |
244 | 251 | // Group results. |
245 | - if ($input->getOption('group-results')) |
|
246 | - $opts->groupResults(); |
|
252 | + if ($input->getOption('group-results')) { |
|
253 | + $opts->groupResults(); |
|
254 | + } |
|
247 | 255 | |
248 | 256 | // Sets group level. |
249 | 257 | $level = (int)$input->getOption('group-level'); |
250 | - if ($level > 0) |
|
251 | - $opts->setGroupLevel($level); |
|
258 | + if ($level > 0) { |
|
259 | + $opts->setGroupLevel($level); |
|
260 | + } |
|
252 | 261 | |
253 | 262 | // Do not reduce. |
254 | - if ($input->getOption('do-not-reduce')) |
|
255 | - $opts->doNotReduce(); |
|
263 | + if ($input->getOption('do-not-reduce')) { |
|
264 | + $opts->doNotReduce(); |
|
265 | + } |
|
256 | 266 | |
257 | 267 | // Includes docs. |
258 | - if ($input->getOption('include-docs')) |
|
259 | - $opts->includeDocs(); |
|
268 | + if ($input->getOption('include-docs')) { |
|
269 | + $opts->includeDocs(); |
|
270 | + } |
|
260 | 271 | |
261 | 272 | // Excludes results. |
262 | - if ($input->getOption('exclude-results')) |
|
263 | - $opts->excludeResults(); |
|
273 | + if ($input->getOption('exclude-results')) { |
|
274 | + $opts->excludeResults(); |
|
275 | + } |
|
264 | 276 | |
265 | 277 | // Excludes endkey. |
266 | - if ($input->getOption('exclude-endkey')) |
|
267 | - $opts->excludeEndKey(); |
|
278 | + if ($input->getOption('exclude-endkey')) { |
|
279 | + $opts->excludeEndKey(); |
|
280 | + } |
|
268 | 281 | |
269 | 282 | // Reverses order of results. |
270 | - if ($input->getOption('reverse-order')) |
|
271 | - $opts->reverseOrderOfResults(); |
|
283 | + if ($input->getOption('reverse-order')) { |
|
284 | + $opts->reverseOrderOfResults(); |
|
285 | + } |
|
272 | 286 | |
273 | 287 | // Skips the defined number of documents. |
274 | 288 | $skip = (int)$input->getOption('skip'); |
275 | - if ($skip > 0) |
|
276 | - $opts->skipDocs($skip); |
|
289 | + if ($skip > 0) { |
|
290 | + $opts->skipDocs($skip); |
|
291 | + } |
|
277 | 292 | |
278 | 293 | // Includes conflicts. |
279 | - if ($input->getOption('include-conflicts')) |
|
280 | - $opts->includeConflicts(); |
|
294 | + if ($input->getOption('include-conflicts')) { |
|
295 | + $opts->includeConflicts(); |
|
296 | + } |
|
281 | 297 | |
282 | 298 | // Includes missing keys. |
283 | - if ($input->getOption('include-missing-keys')) |
|
284 | - $opts->includeMissingKeys(); |
|
299 | + if ($input->getOption('include-missing-keys')) { |
|
300 | + $opts->includeMissingKeys(); |
|
301 | + } |
|
285 | 302 | |
286 | 303 | if ($view == "_temp_view") { |
287 | 304 | |
@@ -289,30 +306,31 @@ discard block |
||
289 | 306 | if ($fileName = $input->getOption('map')) { |
290 | 307 | $map = file_get_contents($fileName); |
291 | 308 | |
292 | - if ($fileName = $input->getOption('reduce')) |
|
293 | - $reduce = file_get_contents($fileName); |
|
294 | - else |
|
295 | - $reduce = ""; |
|
309 | + if ($fileName = $input->getOption('reduce')) { |
|
310 | + $reduce = file_get_contents($fileName); |
|
311 | + } else { |
|
312 | + $reduce = ""; |
|
313 | + } |
|
296 | 314 | |
297 | 315 | $language = $input->getOption('language'); |
298 | - if (empty($language)) |
|
299 | - $language = "php"; |
|
316 | + if (empty($language)) { |
|
317 | + $language = "php"; |
|
318 | + } |
|
319 | + } else { |
|
320 | + throw new \InvalidArgumentException("You didn't provided the map function."); |
|
300 | 321 | } |
301 | - else |
|
302 | - throw new \InvalidArgumentException("You didn't provided the map function."); |
|
303 | 322 | |
304 | 323 | print_r($couch->queryTempView($this->getDatabase(), $map, $reduce, $keys, $opts, $language)); |
305 | - } |
|
306 | - elseif ($view == "_all_docs") { |
|
324 | + } elseif ($view == "_all_docs") { |
|
307 | 325 | print_r($couch->queryAllDocs($this->getDatabase(), $keys, $opts)); |
308 | - } |
|
309 | - else { |
|
326 | + } else { |
|
310 | 327 | $names = explode('/', $view, 2); |
311 | 328 | |
312 | - if (count($names) == 2) |
|
313 | - print_r($couch->queryView($this->getDatabase(), $names[0], $names[1], $keys, $opts)); |
|
314 | - else |
|
315 | - throw new \InvalidArgumentException("You have to specify design-doc/view-name."); |
|
329 | + if (count($names) == 2) { |
|
330 | + print_r($couch->queryView($this->getDatabase(), $names[0], $names[1], $keys, $opts)); |
|
331 | + } else { |
|
332 | + throw new \InvalidArgumentException("You have to specify design-doc/view-name."); |
|
333 | + } |
|
316 | 334 | } |
317 | 335 | |
318 | 336 | } |