/** * Get the batch part identified by the array key (0...n) or its id (if it was set with nextBatchPartId($id) ) * * @throws ClientException * @return mixed $partId */ public function getProcessedResponse() { $response = $this->getResponse(); switch ($this->_type) { case 'getdocument': $json = $response->getJson(); $options = $this->getCursorOptions(); $options['isNew'] = false; $response = Document::createFromArray($json, $options); break; case 'document': $json = $response->getJson(); if ($json['error'] === false) { $id = $json[Document::ENTRY_ID]; $response = $id; } break; case 'getedge': $json = $response->getJson(); $options = $this->getCursorOptions(); $options['isNew'] = false; $response = Edge::createFromArray($json, $options); break; case 'edge': $json = $response->getJson(); if ($json['error'] === false) { $id = $json[Edge::ENTRY_ID]; $response = $id; } break; case 'getcollection': $json = $response->getJson(); $options = $this->getCursorOptions(); $options['isNew'] = false; $response = Collection::createFromArray($json, $options); break; case 'collection': $json = $response->getJson(); if ($json['error'] === false) { $id = $json[Collection::ENTRY_ID]; $response = $id; } break; case 'cursor': $options = $this->getCursorOptions(); $options['isNew'] = false; $response = new Cursor($this->_batch->getConnection(), $response->getJson(), $options); break; default: throw new ClientException('Could not determine response data type.'); break; } return $response; }