Skip to content

Commit 293ba55

Browse files
committed
Improve the API docs
1 parent a435017 commit 293ba55

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

src/PHPCouchDB/Database.php

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,14 @@ public function getDocById($id) : Document
164164
}
165165
}
166166

167+
/**
168+
* Get data from a view, either docs or grouped data
169+
*
170+
* @param array $options Must include `ddoc` and `view`, also suppoerts any
171+
* other query parameters that should be passed to the view (e.g. limit)
172+
* @return array If there are documents, an array of \PHPCouchDB\Document
173+
* objects, otherwise an array as appropriate
174+
*/
167175
public function getView($options = []) : array
168176
{
169177
// check we have ddoc and view name
@@ -210,6 +218,18 @@ public function getView($options = []) : array
210218
return $data;
211219
}
212220

221+
/**
222+
* Take a result set, work out if it contains docs, doc tombstones, or
223+
* data that we shouldn't mess with, and return \Document objects or arrays
224+
* as appropriate
225+
*
226+
* @param \GuzzleHttp\Message\ResponseInterface $response What we got back
227+
* from making a Guzzle request to the CouchDB server
228+
* @return array An array whose contents depends on the response content:
229+
* - an array of full CouchDB docs: returns array of \PHPCouchDB\Document
230+
* - an array of id/rev pairs from docs: returns an array of arrays containing id/rev
231+
* - an array of anything else: returns it just as an array
232+
*/
213233
protected function handleServerResponse($response) : array
214234
{
215235
if ($response->getStatusCode() == 200) {
@@ -247,9 +267,9 @@ protected function handleServerResponse($response) : array
247267
* Guzzle doesn't send booleans as words
248268
*
249269
* @param mixed $value The value to use
250-
* @return A string either "true" or "false"
270+
* @return string A string either "true" or "false"
251271
*/
252-
protected function boolToString($value)
272+
protected function boolToString($value) : string
253273
{
254274
if ($value) {
255275
return "true";

0 commit comments

Comments
 (0)