@@ -69,9 +69,9 @@ discard block |
||
| 69 | 69 | * Check for Cross-Driver type confusion |
| 70 | 70 | */ |
| 71 | 71 | if ($item instanceof Item) { |
| 72 | - try{ |
|
| 72 | + try { |
|
| 73 | 73 | $this->instance->putDocument(['data' => $this->encode($this->driverPreWrap($item))], $item->getEncodedKey(), $this->getLatestDocumentRevision($item->getEncodedKey())); |
| 74 | - }catch (CouchDBException $e){ |
|
| 74 | + } catch (CouchDBException $e) { |
|
| 75 | 75 | throw new phpFastCacheDriverException('Got error while trying to upsert a document: ' . $e->getMessage(), null, $e); |
| 76 | 76 | } |
| 77 | 77 | return true; |
@@ -87,17 +87,17 @@ discard block |
||
| 87 | 87 | */ |
| 88 | 88 | protected function driverRead(CacheItemInterface $item) |
| 89 | 89 | { |
| 90 | - try{ |
|
| 90 | + try { |
|
| 91 | 91 | $response = $this->instance->findDocument($item->getEncodedKey()); |
| 92 | - }catch (CouchDBException $e){ |
|
| 92 | + } catch (CouchDBException $e) { |
|
| 93 | 93 | throw new phpFastCacheDriverException('Got error while trying to get a document: ' . $e->getMessage(), null, $e); |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - if($response->status === 404 || empty($response->body['data'])){ |
|
| 96 | + if ($response->status === 404 || empty($response->body['data'])) { |
|
| 97 | 97 | return null; |
| 98 | - }else if($response->status === 200){ |
|
| 98 | + } else if ($response->status === 200) { |
|
| 99 | 99 | return $this->decode($response->body['data']); |
| 100 | - }else{ |
|
| 100 | + } else { |
|
| 101 | 101 | throw new phpFastCacheDriverException('Got unexpected HTTP status: ' . $response->status); |
| 102 | 102 | } |
| 103 | 103 | } |
@@ -114,9 +114,9 @@ discard block |
||
| 114 | 114 | * Check for Cross-Driver type confusion |
| 115 | 115 | */ |
| 116 | 116 | if ($item instanceof Item) { |
| 117 | - try{ |
|
| 117 | + try { |
|
| 118 | 118 | $this->instance->deleteDocument($item->getEncodedKey(), $this->getLatestDocumentRevision($item->getEncodedKey())); |
| 119 | - }catch (CouchDBException $e){ |
|
| 119 | + } catch (CouchDBException $e) { |
|
| 120 | 120 | throw new phpFastCacheDriverException('Got error while trying to delete a document: ' . $e->getMessage(), null, $e); |
| 121 | 121 | } |
| 122 | 122 | return true; |
@@ -131,10 +131,10 @@ discard block |
||
| 131 | 131 | */ |
| 132 | 132 | protected function driverClear() |
| 133 | 133 | { |
| 134 | - try{ |
|
| 134 | + try { |
|
| 135 | 135 | $this->instance->deleteDatabase($this->getDatabaseName()); |
| 136 | 136 | $this->createDatabase(); |
| 137 | - }catch (CouchDBException $e){ |
|
| 137 | + } catch (CouchDBException $e) { |
|
| 138 | 138 | throw new phpFastCacheDriverException('Got error while trying to delete and recreate the database: ' . $e->getMessage(), null, $e); |
| 139 | 139 | } |
| 140 | 140 | |
@@ -150,19 +150,19 @@ discard block |
||
| 150 | 150 | if ($this->instance instanceof CouchdbClient) { |
| 151 | 151 | throw new \LogicException('Already connected to Couchdb server'); |
| 152 | 152 | } else { |
| 153 | - $host = isset($this->config[ 'host' ]) ? $this->config[ 'host' ] : '127.0.0.1'; |
|
| 154 | - $ssl = isset($this->config[ 'ssl' ]) ? $this->config[ 'ssl' ] : false; |
|
| 155 | - $port = isset($this->config[ 'port' ]) ? $this->config[ 'port' ] : 5984; |
|
| 156 | - $path = isset($this->config[ 'path' ]) ? $this->config[ 'path' ] : '/'; |
|
| 157 | - $username = isset($this->config[ 'username' ]) ? $this->config[ 'username' ] : ''; |
|
| 158 | - $password = isset($this->config[ 'password' ]) ? $this->config[ 'password' ] : ''; |
|
| 159 | - $timeout = isset($this->config[ 'timeout' ]) ? $this->config[ 'timeout' ] : 10; |
|
| 153 | + $host = isset($this->config['host']) ? $this->config['host'] : '127.0.0.1'; |
|
| 154 | + $ssl = isset($this->config['ssl']) ? $this->config['ssl'] : false; |
|
| 155 | + $port = isset($this->config['port']) ? $this->config['port'] : 5984; |
|
| 156 | + $path = isset($this->config['path']) ? $this->config['path'] : '/'; |
|
| 157 | + $username = isset($this->config['username']) ? $this->config['username'] : ''; |
|
| 158 | + $password = isset($this->config['password']) ? $this->config['password'] : ''; |
|
| 159 | + $timeout = isset($this->config['timeout']) ? $this->config['timeout'] : 10; |
|
| 160 | 160 | |
| 161 | 161 | $url = ($ssl ? 'https://' : 'http://'); |
| 162 | - if($username) |
|
| 162 | + if ($username) |
|
| 163 | 163 | { |
| 164 | 164 | $url .= "{$username}"; |
| 165 | - if($password) |
|
| 165 | + if ($password) |
|
| 166 | 166 | { |
| 167 | 167 | $url .= ":{$password}"; |
| 168 | 168 | } |
@@ -192,14 +192,14 @@ discard block |
||
| 192 | 192 | $path = '/' . $this->getDatabaseName() . '/' . urlencode($docId); |
| 193 | 193 | |
| 194 | 194 | $response = $this->instance->getHttpClient()->request( |
| 195 | - 'GET',// At this moment HEAD requests are not working: https://github.com/doctrine/couchdb-client/issues/72 |
|
| 195 | + 'GET', // At this moment HEAD requests are not working: https://github.com/doctrine/couchdb-client/issues/72 |
|
| 196 | 196 | $path, |
| 197 | 197 | null, |
| 198 | 198 | false |
| 199 | 199 | ); |
| 200 | - if(!empty($response->headers['etag'])){ |
|
| 200 | + if (!empty($response->headers['etag'])) { |
|
| 201 | 201 | return trim($response->headers['etag'], " '\"\t\n\r\0\x0B"); |
| 202 | - }else{ |
|
| 202 | + } else { |
|
| 203 | 203 | return null; |
| 204 | 204 | } |
| 205 | 205 | } |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | */ |
| 210 | 210 | protected function getDatabaseName() |
| 211 | 211 | { |
| 212 | - return isset($this->config[ 'database' ]) ? $this->config[ 'database' ] : 'phpfastcache'; |
|
| 212 | + return isset($this->config['database']) ? $this->config['database'] : 'phpfastcache'; |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | /** |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | */ |
| 218 | 218 | protected function createDatabase() |
| 219 | 219 | { |
| 220 | - if(!in_array($this->instance->getDatabase(), $this->instance->getAllDatabases(), true)){ |
|
| 220 | + if (!in_array($this->instance->getDatabase(), $this->instance->getAllDatabases(), true)) { |
|
| 221 | 221 | $this->instance->createDatabase($this->instance->getDatabase()); |
| 222 | 222 | } |
| 223 | 223 | } |