@@ -76,10 +76,9 @@ public function getAllDocs($options = []) : array
76
76
// grab extra params
77
77
$ query = $ options ;
78
78
79
- // set some defaults
80
- if (isset ($ query ['include_docs ' ]) && $ query ['include_docs ' ] == false ) {
81
- // needs to be a string
82
- $ query ['include_docs ' ] = "false " ;
79
+ // convert data and set some defaults
80
+ if (isset ($ query ['include_docs ' ])) {
81
+ $ query ['include_docs ' ] = $ this ->boolToString ($ query ['include_docs ' ]);
83
82
} else {
84
83
// needs to be a string and this is our chosen default value
85
84
$ query ['include_docs ' ] = "true " ;
@@ -191,15 +190,21 @@ public function getView($options = []) : array
191
190
}
192
191
}
193
192
194
- // set some defaults
195
- if (isset ($ query ['include_docs ' ]) && $ query ['include_docs ' ] == true ) {
196
- // needs to be a string
197
- $ query ['include_docs ' ] = "true " ;
193
+ // convert data and set some defaults
194
+ if (isset ($ query ['include_docs ' ])) {
195
+ $ query ['include_docs ' ] = $ this ->boolToString ($ query ['include_docs ' ]);
198
196
} else {
199
197
// needs to be a string and this is our chosen default value
200
198
$ query ['include_docs ' ] = "false " ;
201
199
}
202
200
201
+ if (isset ($ query ['reduce ' ])) {
202
+ $ query ['reduce ' ] = $ this ->boolToString ($ query ['reduce ' ]);
203
+ } else {
204
+ // needs to be a string and this is our chosen default value
205
+ $ query ['reduce ' ] = "true " ;
206
+ }
207
+
203
208
$ response = $ this ->client ->request ("GET " , $ endpoint , ["query " => $ query ]);
204
209
$ data = $ this ->handleServerResponse ($ response );
205
210
return $ data ;
@@ -236,4 +241,19 @@ protected function handleServerResponse($response) : array
236
241
}
237
242
}
238
243
}
244
+
245
+ /**
246
+ * Convert truthy things to "true" and the rest to "false" because
247
+ * Guzzle doesn't send booleans as words
248
+ *
249
+ * @param mixed $value The value to use
250
+ * @return A string either "true" or "false"
251
+ */
252
+ protected function boolToString ($ value ) {
253
+ if ($ value ) {
254
+ return "true " ;
255
+ } else {
256
+ return "false " ;
257
+ }
258
+ }
239
259
}
0 commit comments