@@ -54,7 +54,7 @@ public function getAllDocs($options = []) : array
54
54
}
55
55
return $ docs ;
56
56
} else {
57
- throw new \ PHPCouchDB \ Exception \ServerException ('JSON response not received or not understood ' );
57
+ throw new Exception \ServerException ('JSON response not received or not understood ' );
58
58
}
59
59
}
60
60
}
@@ -71,7 +71,7 @@ public function getAllDocs($options = []) : array
71
71
public function create ($ doc )
72
72
{
73
73
if (!is_array ($ doc )) {
74
- throw new \ PHPCouchDB \ Exception \DatabaseException ('A document is required, in array format ' );
74
+ throw new Exception \DatabaseException ('A document is required, in array format ' );
75
75
}
76
76
77
77
// do we have the ID?
@@ -93,10 +93,10 @@ public function create($doc)
93
93
$ id = $ response_data ['id ' ];
94
94
// all good. Let's fetch the doc and return it
95
95
$ fetched_data = json_decode ($ this ->client ->get ('/ ' . $ this ->db_name . '/ ' . $ id )->getBody ());
96
- return new \ PHPCouchDB \ Document ($ fetched_data );
96
+ return new Document ($ this -> client , $ this -> db_name , $ fetched_data );
97
97
}
98
98
} catch (\GuzzleHttp \Exception \ConnectException $ e ) {
99
- throw new \ PHPCouchDB \ Exception \ServerException (
99
+ throw new Exception \ServerException (
100
100
"Could not create record. Error: " . $ e ->getMessage (),
101
101
0 ,
102
102
$ e
@@ -112,7 +112,7 @@ public function create($doc)
112
112
* @throws PHPCouchDB\Exception\ServerException if the response can't be understood
113
113
* @throws PHPCouchDB\Exception\DatabaseException if the doc isn't found
114
114
*/
115
- public function getDocById ($ id ) : \ PHPCouchDB \ Document
115
+ public function getDocById ($ id ) : Document
116
116
{
117
117
$ endpoint = "/ " . $ this ->db_name . "/ " . $ id ;
118
118
$ response = $ this ->client ->request ("GET " , $ endpoint );
@@ -121,10 +121,10 @@ public function getDocById($id) : \PHPCouchDB\Document
121
121
$ doc = new Document ($ this ->client , $ this ->db_name , $ data );
122
122
return $ doc ;
123
123
} else {
124
- throw new \ PHPCouchDB \ Exception \ServerException ('JSON response not received or not understood ' );
124
+ throw new Exception \ServerException ('JSON response not received or not understood ' );
125
125
}
126
126
} else {
127
- throw new \ PHPCouchDB \ Exception \DatabaseException ('Document not found ' );
127
+ throw new Exception \DatabaseException ('Document not found ' );
128
128
}
129
129
}
130
130
}
0 commit comments