@@ -17,6 +17,8 @@ class Database
1717 protected $ client ;
1818 protected $ db_name ;
1919
20+ const OPTION_INCLUDE_DOCS = 'include_docs ' ;
21+ const OPTION_REDUCE = 'reduce ' ;
2022
2123 /**
2224 * Constructor for the Database object - this is usually called by
@@ -77,11 +79,13 @@ public function getAllDocs($options = []) : array
7779 $ query = $ options ;
7880
7981 // 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+ );
8286 } else {
8387 // needs to be a string and this is our chosen default value
84- $ query [' include_docs ' ] = "true " ;
88+ $ query [self :: OPTION_INCLUDE_DOCS ] = "true " ;
8589 }
8690
8791 $ response = $ this ->client ->request ("GET " , $ endpoint , ["query " => $ query ]);
@@ -167,7 +171,7 @@ public function getDocById($id) : Document
167171 /**
168172 * Get data from a view, either docs or grouped data
169173 *
170- * @param array $options Must include `ddoc` and `view`, also suppoerts any
174+ * @param array $options Must include `ddoc` and `view`, also supports any
171175 * other query parameters that should be passed to the view (e.g. limit)
172176 * @return array If there are documents, an array of \PHPCouchDB\Document
173177 * objects, otherwise an array as appropriate
@@ -199,18 +203,22 @@ public function getView($options = []) : array
199203 }
200204
201205 // 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+ );
204210 } else {
205211 // needs to be a string and this is our chosen default value
206- $ query [' include_docs ' ] = "false " ;
212+ $ query [self :: OPTION_INCLUDE_DOCS ] = "true " ;
207213 }
208214
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+ );
211219 } else {
212220 // needs to be a string and this is our chosen default value
213- $ query [' reduce ' ] = "true " ;
221+ $ query [self :: OPTION_REDUCE ] = "true " ;
214222 }
215223
216224 $ response = $ this ->client ->request ("GET " , $ endpoint , ["query " => $ query ]);
0 commit comments