@@ -175,9 +175,9 @@ discard block |
||
| 175 | 175 | $url .= $path; |
| 176 | 176 | |
| 177 | 177 | $this->instance = CouchDBClient::create([ |
| 178 | - 'dbname' => $this->getDatabaseName(), |
|
| 179 | - 'url' => $url, |
|
| 180 | - 'timeout' => $timeout |
|
| 178 | + 'dbname' => $this->getDatabaseName(), |
|
| 179 | + 'url' => $url, |
|
| 180 | + 'timeout' => $timeout |
|
| 181 | 181 | ]); |
| 182 | 182 | |
| 183 | 183 | $this->createDatabase(); |
@@ -194,10 +194,10 @@ discard block |
||
| 194 | 194 | $path = '/' . $this->getDatabaseName() . '/' . urlencode($docId); |
| 195 | 195 | |
| 196 | 196 | $response = $this->instance->getHttpClient()->request( |
| 197 | - 'HEAD', |
|
| 198 | - $path, |
|
| 199 | - null, |
|
| 200 | - false |
|
| 197 | + 'HEAD', |
|
| 198 | + $path, |
|
| 199 | + null, |
|
| 200 | + false |
|
| 201 | 201 | ); |
| 202 | 202 | if(!empty($response->headers['etag'])){ |
| 203 | 203 | return trim($response->headers['etag'], " '\"\t\n\r\0\x0B"); |
@@ -251,9 +251,9 @@ discard block |
||
| 251 | 251 | $info = $this->instance->getDatabaseInfo(); |
| 252 | 252 | |
| 253 | 253 | return (new DriverStatistic()) |
| 254 | - ->setSize($info['sizes']['active']) |
|
| 255 | - ->setRawData($info) |
|
| 256 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 257 | - ->setInfo('Couchdb version ' . $this->instance->getVersion() . "\n For more information see RawData."); |
|
| 254 | + ->setSize($info['sizes']['active']) |
|
| 255 | + ->setRawData($info) |
|
| 256 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 257 | + ->setInfo('Couchdb version ' . $this->instance->getVersion() . "\n For more information see RawData."); |
|
| 258 | 258 | } |
| 259 | 259 | } |
| 260 | 260 | \ No newline at end of file |
@@ -70,9 +70,9 @@ discard block |
||
| 70 | 70 | * Check for Cross-Driver type confusion |
| 71 | 71 | */ |
| 72 | 72 | if ($item instanceof Item) { |
| 73 | - try{ |
|
| 73 | + try { |
|
| 74 | 74 | $this->instance->putDocument(['data' => $this->encode($this->driverPreWrap($item))], $item->getEncodedKey(), $this->getLatestDocumentRevision($item->getEncodedKey())); |
| 75 | - }catch (CouchDBException $e){ |
|
| 75 | + } catch (CouchDBException $e) { |
|
| 76 | 76 | throw new phpFastCacheDriverException('Got error while trying to upsert a document: ' . $e->getMessage(), null, $e); |
| 77 | 77 | } |
| 78 | 78 | return true; |
@@ -88,17 +88,17 @@ discard block |
||
| 88 | 88 | */ |
| 89 | 89 | protected function driverRead(CacheItemInterface $item) |
| 90 | 90 | { |
| 91 | - try{ |
|
| 91 | + try { |
|
| 92 | 92 | $response = $this->instance->findDocument($item->getEncodedKey()); |
| 93 | - }catch (CouchDBException $e){ |
|
| 93 | + } catch (CouchDBException $e) { |
|
| 94 | 94 | throw new phpFastCacheDriverException('Got error while trying to get a document: ' . $e->getMessage(), null, $e); |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - if($response->status === 404 || empty($response->body['data'])){ |
|
| 97 | + if ($response->status === 404 || empty($response->body['data'])) { |
|
| 98 | 98 | return null; |
| 99 | - }else if($response->status === 200){ |
|
| 99 | + } else if ($response->status === 200) { |
|
| 100 | 100 | return $this->decode($response->body['data']); |
| 101 | - }else{ |
|
| 101 | + } else { |
|
| 102 | 102 | throw new phpFastCacheDriverException('Got unexpected HTTP status: ' . $response->status); |
| 103 | 103 | } |
| 104 | 104 | } |
@@ -115,9 +115,9 @@ discard block |
||
| 115 | 115 | * Check for Cross-Driver type confusion |
| 116 | 116 | */ |
| 117 | 117 | if ($item instanceof Item) { |
| 118 | - try{ |
|
| 118 | + try { |
|
| 119 | 119 | $this->instance->deleteDocument($item->getEncodedKey(), $this->getLatestDocumentRevision($item->getEncodedKey())); |
| 120 | - }catch (CouchDBException $e){ |
|
| 120 | + } catch (CouchDBException $e) { |
|
| 121 | 121 | throw new phpFastCacheDriverException('Got error while trying to delete a document: ' . $e->getMessage(), null, $e); |
| 122 | 122 | } |
| 123 | 123 | return true; |
@@ -132,10 +132,10 @@ discard block |
||
| 132 | 132 | */ |
| 133 | 133 | protected function driverClear() |
| 134 | 134 | { |
| 135 | - try{ |
|
| 135 | + try { |
|
| 136 | 136 | $this->instance->deleteDatabase($this->getDatabaseName()); |
| 137 | 137 | $this->createDatabase(); |
| 138 | - }catch (CouchDBException $e){ |
|
| 138 | + } catch (CouchDBException $e) { |
|
| 139 | 139 | throw new phpFastCacheDriverException('Got error while trying to delete and recreate the database: ' . $e->getMessage(), null, $e); |
| 140 | 140 | } |
| 141 | 141 | |
@@ -152,19 +152,19 @@ discard block |
||
| 152 | 152 | if ($this->instance instanceof CouchdbClient) { |
| 153 | 153 | throw new phpFastCacheLogicException('Already connected to Couchdb server'); |
| 154 | 154 | } else { |
| 155 | - $host = isset($this->config[ 'host' ]) ? $this->config[ 'host' ] : '127.0.0.1'; |
|
| 156 | - $ssl = isset($this->config[ 'ssl' ]) ? $this->config[ 'ssl' ] : false; |
|
| 157 | - $port = isset($this->config[ 'port' ]) ? $this->config[ 'port' ] : 5984; |
|
| 158 | - $path = isset($this->config[ 'path' ]) ? $this->config[ 'path' ] : '/'; |
|
| 159 | - $username = isset($this->config[ 'username' ]) ? $this->config[ 'username' ] : ''; |
|
| 160 | - $password = isset($this->config[ 'password' ]) ? $this->config[ 'password' ] : ''; |
|
| 161 | - $timeout = isset($this->config[ 'timeout' ]) ? $this->config[ 'timeout' ] : 10; |
|
| 155 | + $host = isset($this->config['host']) ? $this->config['host'] : '127.0.0.1'; |
|
| 156 | + $ssl = isset($this->config['ssl']) ? $this->config['ssl'] : false; |
|
| 157 | + $port = isset($this->config['port']) ? $this->config['port'] : 5984; |
|
| 158 | + $path = isset($this->config['path']) ? $this->config['path'] : '/'; |
|
| 159 | + $username = isset($this->config['username']) ? $this->config['username'] : ''; |
|
| 160 | + $password = isset($this->config['password']) ? $this->config['password'] : ''; |
|
| 161 | + $timeout = isset($this->config['timeout']) ? $this->config['timeout'] : 10; |
|
| 162 | 162 | |
| 163 | 163 | $url = ($ssl ? 'https://' : 'http://'); |
| 164 | - if($username) |
|
| 164 | + if ($username) |
|
| 165 | 165 | { |
| 166 | 166 | $url .= "{$username}"; |
| 167 | - if($password) |
|
| 167 | + if ($password) |
|
| 168 | 168 | { |
| 169 | 169 | $url .= ":{$password}"; |
| 170 | 170 | } |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | null, |
| 200 | 200 | false |
| 201 | 201 | ); |
| 202 | - if(!empty($response->headers['etag'])){ |
|
| 202 | + if (!empty($response->headers['etag'])) { |
|
| 203 | 203 | return trim($response->headers['etag'], " '\"\t\n\r\0\x0B"); |
| 204 | 204 | } |
| 205 | 205 | |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | */ |
| 212 | 212 | protected function getDatabaseName() |
| 213 | 213 | { |
| 214 | - return isset($this->config[ 'database' ]) ? $this->config[ 'database' ] : 'phpfastcache'; |
|
| 214 | + return isset($this->config['database']) ? $this->config['database'] : 'phpfastcache'; |
|
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | /** |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | */ |
| 220 | 220 | protected function createDatabase() |
| 221 | 221 | { |
| 222 | - if(!in_array($this->instance->getDatabase(), $this->instance->getAllDatabases(), true)){ |
|
| 222 | + if (!in_array($this->instance->getDatabase(), $this->instance->getAllDatabases(), true)) { |
|
| 223 | 223 | $this->instance->createDatabase($this->instance->getDatabase()); |
| 224 | 224 | } |
| 225 | 225 | } |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | if ($item instanceof Item) { |
| 73 | 73 | try{ |
| 74 | 74 | $this->instance->putDocument(['data' => $this->encode($this->driverPreWrap($item))], $item->getEncodedKey(), $this->getLatestDocumentRevision($item->getEncodedKey())); |
| 75 | - }catch (CouchDBException $e){ |
|
| 75 | + } catch (CouchDBException $e){ |
|
| 76 | 76 | throw new phpFastCacheDriverException('Got error while trying to upsert a document: ' . $e->getMessage(), null, $e); |
| 77 | 77 | } |
| 78 | 78 | return true; |
@@ -90,15 +90,15 @@ discard block |
||
| 90 | 90 | { |
| 91 | 91 | try{ |
| 92 | 92 | $response = $this->instance->findDocument($item->getEncodedKey()); |
| 93 | - }catch (CouchDBException $e){ |
|
| 93 | + } catch (CouchDBException $e){ |
|
| 94 | 94 | throw new phpFastCacheDriverException('Got error while trying to get a document: ' . $e->getMessage(), null, $e); |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | if($response->status === 404 || empty($response->body['data'])){ |
| 98 | 98 | return null; |
| 99 | - }else if($response->status === 200){ |
|
| 99 | + } else if($response->status === 200){ |
|
| 100 | 100 | return $this->decode($response->body['data']); |
| 101 | - }else{ |
|
| 101 | + } else{ |
|
| 102 | 102 | throw new phpFastCacheDriverException('Got unexpected HTTP status: ' . $response->status); |
| 103 | 103 | } |
| 104 | 104 | } |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | if ($item instanceof Item) { |
| 118 | 118 | try{ |
| 119 | 119 | $this->instance->deleteDocument($item->getEncodedKey(), $this->getLatestDocumentRevision($item->getEncodedKey())); |
| 120 | - }catch (CouchDBException $e){ |
|
| 120 | + } catch (CouchDBException $e){ |
|
| 121 | 121 | throw new phpFastCacheDriverException('Got error while trying to delete a document: ' . $e->getMessage(), null, $e); |
| 122 | 122 | } |
| 123 | 123 | return true; |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | try{ |
| 136 | 136 | $this->instance->deleteDatabase($this->getDatabaseName()); |
| 137 | 137 | $this->createDatabase(); |
| 138 | - }catch (CouchDBException $e){ |
|
| 138 | + } catch (CouchDBException $e){ |
|
| 139 | 139 | throw new phpFastCacheDriverException('Got error while trying to delete and recreate the database: ' . $e->getMessage(), null, $e); |
| 140 | 140 | } |
| 141 | 141 | |