@@ -17,6 +17,8 @@ class Database
17
17
protected $ client ;
18
18
protected $ db_name ;
19
19
20
+ const OPTION_INCLUDE_DOCS = 'include_docs ' ;
21
+ const OPTION_REDUCE = 'reduce ' ;
20
22
21
23
/**
22
24
* Constructor for the Database object - this is usually called by
@@ -77,11 +79,13 @@ public function getAllDocs($options = []) : array
77
79
$ query = $ options ;
78
80
79
81
// convert data and set some defaults
80
- if (isset ($ query ['include_docs ' ])) {
81
- $ query ['include_docs ' ] = $ this ->boolToString ($ query ['include_docs ' ]);
82
+ if (isset ($ query [self ::OPTION_INCLUDE_DOCS ])) {
83
+ $ query [self ::OPTION_INCLUDE_DOCS ] = $ this ->boolToString (
84
+ $ query [self ::OPTION_INCLUDE_DOCS ]
85
+ );
82
86
} else {
83
87
// needs to be a string and this is our chosen default value
84
- $ query [' include_docs ' ] = "true " ;
88
+ $ query [self :: OPTION_INCLUDE_DOCS ] = "true " ;
85
89
}
86
90
87
91
$ response = $ this ->client ->request ("GET " , $ endpoint , ["query " => $ query ]);
@@ -167,7 +171,7 @@ public function getDocById($id) : Document
167
171
/**
168
172
* Get data from a view, either docs or grouped data
169
173
*
170
- * @param array $options Must include `ddoc` and `view`, also suppoerts any
174
+ * @param array $options Must include `ddoc` and `view`, also supports any
171
175
* other query parameters that should be passed to the view (e.g. limit)
172
176
* @return array If there are documents, an array of \PHPCouchDB\Document
173
177
* objects, otherwise an array as appropriate
@@ -199,18 +203,22 @@ public function getView($options = []) : array
199
203
}
200
204
201
205
// convert data and set some defaults
202
- if (isset ($ query ['include_docs ' ])) {
203
- $ query ['include_docs ' ] = $ this ->boolToString ($ query ['include_docs ' ]);
206
+ if (isset ($ query [self ::OPTION_INCLUDE_DOCS ])) {
207
+ $ query [self ::OPTION_INCLUDE_DOCS ] = $ this ->boolToString (
208
+ $ query [self ::OPTION_INCLUDE_DOCS ]
209
+ );
204
210
} else {
205
211
// needs to be a string and this is our chosen default value
206
- $ query [' include_docs ' ] = "false " ;
212
+ $ query [self :: OPTION_INCLUDE_DOCS ] = "true " ;
207
213
}
208
214
209
- if (isset ($ query ['reduce ' ])) {
210
- $ query ['reduce ' ] = $ this ->boolToString ($ query ['reduce ' ]);
215
+ if (isset ($ query [self ::OPTION_REDUCE ])) {
216
+ $ query [self ::OPTION_REDUCE ] = $ this ->boolToString (
217
+ $ query [self ::OPTION_REDUCE ]
218
+ );
211
219
} else {
212
220
// needs to be a string and this is our chosen default value
213
- $ query [' reduce ' ] = "true " ;
221
+ $ query [self :: OPTION_REDUCE ] = "true " ;
214
222
}
215
223
216
224
$ response = $ this ->client ->request ("GET " , $ endpoint , ["query " => $ query ]);
0 commit comments