Code Duplication    Length = 10-11 lines in 3 locations

src/CouchDB/Connection.php 1 location

@@ 115-124 (lines=10) @@
112
     *
113
     * @return Database
114
     */
115
    public function selectDatabase($name)
116
    {
117
        $response = $this->client->request('GET', sprintf('/%s/', $name));
118
119
        if (404 === $response->getStatusCode()) {
120
            throw new Exception(sprintf('The database "%s" does not exist', $name));
121
        }
122
123
        return $this->wrapDatabase($name);
124
    }
125
126
    /**
127
     * Check if a database exists.

src/CouchDB/Database.php 2 locations

@@ 60-70 (lines=11) @@
57
     *
58
     * @return mixed
59
     */
60
    public function find($id)
61
    {
62
        $response = $this->client->request('GET', sprintf('/%s/%s', $this->name, $id));
63
        $json = (string) $response->getBody();
64
65
        if (404 === $response->getStatusCode()) {
66
            throw new Exception('Document does not exist');
67
        }
68
69
        return JSONEncoder::decode($json);
70
    }
71
72
    /**
73
     * Find all documents from the database.
@@ 198-207 (lines=10) @@
195
     *
196
     * @return bool
197
     */
198
    public function delete($id, $rev)
199
    {
200
        $response = $this->client->request('DELETE', "/{$this->name}/{$id}?rev={$rev}");
201
202
        if (200 !== $response->getStatusCode()) {
203
            throw new Exception(sprintf('Unable to delete %s', $id));
204
        }
205
206
        return true;
207
    }
208
209
    /**
210
     * Creates a batch updater.