/** * @param CouchDBClient $studentClient * @param CouchDBClient $solutionClient * @throws \Doctrine\CouchDB\HTTP\HTTPException */ private function replicateDbFromStudentToSolution(CouchDBClient $studentClient, CouchDBClient $solutionClient) { $response = $studentClient->allDocs(); if ($response->status !== 200) { //should maybe throw an exception - but what should we print? return; } foreach ($response->body['rows'] as $row) { $doc = $row['doc']; $data = array_filter($doc, function ($key) { return !in_array($key, ['_id', '_rev']); }, ARRAY_FILTER_USE_KEY); try { $solutionClient->putDocument($data, $doc['_id'], $doc['_rev']); } catch (HTTPException $e) { } } }