@@ -26,8 +26,7 @@ |
||
| 26 | 26 | /** |
| 27 | 27 | * @inheritdoc |
| 28 | 28 | */ |
| 29 | - public function __construct($message = "", $code = 0, $previous = null) |
|
| 30 | - { |
|
| 29 | + public function __construct($message = "", $code = 0, $previous = null) { |
|
| 31 | 30 | $lastError = error_get_last(); |
| 32 | 31 | if ($lastError) { |
| 33 | 32 | $message .= "\n"; |
@@ -28,8 +28,7 @@ |
||
| 28 | 28 | * @param string $expectedType |
| 29 | 29 | * @param mixed $unexpectedData |
| 30 | 30 | */ |
| 31 | - public function __construct($expectedType, $unexpectedData) |
|
| 32 | - { |
|
| 31 | + public function __construct($expectedType, $unexpectedData) { |
|
| 33 | 32 | $type = gettype($unexpectedData); |
| 34 | 33 | parent::__construct("Expecting '{$expectedType}', got '" . ($type === 'object' ? $type . '(' . get_class($type) . ')' : $type) . "'"); |
| 35 | 34 | } |
@@ -38,8 +38,7 @@ discard block |
||
| 38 | 38 | * @param $key |
| 39 | 39 | * @throws PhpfastcacheInvalidArgumentException |
| 40 | 40 | */ |
| 41 | - public function __construct(CouchdbDriver $driver, $key) |
|
| 42 | - { |
|
| 41 | + public function __construct(CouchdbDriver $driver, $key) { |
|
| 43 | 42 | $this->__BaseConstruct($driver, $key); |
| 44 | 43 | } |
| 45 | 44 | |
@@ -48,8 +47,7 @@ discard block |
||
| 48 | 47 | * @return static |
| 49 | 48 | * @throws PhpfastcacheInvalidArgumentException |
| 50 | 49 | */ |
| 51 | - public function setDriver(ExtendedCacheItemPoolInterface $driver) |
|
| 52 | - { |
|
| 50 | + public function setDriver(ExtendedCacheItemPoolInterface $driver) { |
|
| 53 | 51 | if ($driver instanceof CouchdbDriver) { |
| 54 | 52 | $this->driver = $driver; |
| 55 | 53 | |
@@ -120,17 +120,16 @@ discard block |
||
| 120 | 120 | /** |
| 121 | 121 | * @return void |
| 122 | 122 | */ |
| 123 | - protected function createDatabase() |
|
| 124 | - { |
|
| 123 | + protected function createDatabase() { |
|
| 125 | 124 | try{ |
| 126 | 125 | $this->instance->getDatabaseInfo($this->getDatabaseName()); |
| 127 | - } catch(HTTPException $e){ |
|
| 126 | + } |
|
| 127 | + catch(HTTPException $e){ |
|
| 128 | 128 | $this->instance->createDatabase($this->getDatabaseName()); |
| 129 | 129 | } |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | - protected function getCouchDbItemKey(CacheItemInterface $item) |
|
| 133 | - { |
|
| 132 | + protected function getCouchDbItemKey(CacheItemInterface $item) { |
|
| 134 | 133 | return 'pfc_' . $item->getEncodedKey(); |
| 135 | 134 | } |
| 136 | 135 | |
@@ -139,11 +138,11 @@ discard block |
||
| 139 | 138 | * @return null|array |
| 140 | 139 | * @throws PhpfastcacheDriverException |
| 141 | 140 | */ |
| 142 | - protected function driverRead(CacheItemInterface $item) |
|
| 143 | - { |
|
| 141 | + protected function driverRead(CacheItemInterface $item) { |
|
| 144 | 142 | try { |
| 145 | 143 | $response = $this->instance->findDocument($this->getCouchDbItemKey($item)); |
| 146 | - } catch (CouchDBException $e) { |
|
| 144 | + } |
|
| 145 | + catch (CouchDBException $e) { |
|
| 147 | 146 | throw new PhpfastcacheDriverException('Got error while trying to get a document: ' . $e->getMessage(), 0, $e); |
| 148 | 147 | } |
| 149 | 148 | |
@@ -176,7 +175,8 @@ discard block |
||
| 176 | 175 | $this->getCouchDbItemKey($item), |
| 177 | 176 | $this->getLatestDocumentRevision($this->getCouchDbItemKey($item)) |
| 178 | 177 | ); |
| 179 | - } catch (CouchDBException $e) { |
|
| 178 | + } |
|
| 179 | + catch (CouchDBException $e) { |
|
| 180 | 180 | throw new PhpfastcacheDriverException('Got error while trying to upsert a document: ' . $e->getMessage(), 0, $e); |
| 181 | 181 | } |
| 182 | 182 | return true; |
@@ -188,8 +188,7 @@ discard block |
||
| 188 | 188 | /** |
| 189 | 189 | * @return string|null |
| 190 | 190 | */ |
| 191 | - protected function getLatestDocumentRevision($docId) |
|
| 192 | - { |
|
| 191 | + protected function getLatestDocumentRevision($docId) { |
|
| 193 | 192 | $path = '/' . \urlencode($this->getDatabaseName()) . '/' . urlencode($docId); |
| 194 | 193 | |
| 195 | 194 | $response = $this->instance->getHttpClient()->request( |
@@ -225,7 +224,8 @@ discard block |
||
| 225 | 224 | if ($item instanceof Item) { |
| 226 | 225 | try { |
| 227 | 226 | $this->instance->deleteDocument($this->getCouchDbItemKey($item), $this->getLatestDocumentRevision($this->getCouchDbItemKey($item))); |
| 228 | - } catch (CouchDBException $e) { |
|
| 227 | + } |
|
| 228 | + catch (CouchDBException $e) { |
|
| 229 | 229 | throw new PhpfastcacheDriverException('Got error while trying to delete a document: ' . $e->getMessage(), 0, $e); |
| 230 | 230 | } |
| 231 | 231 | return true; |
@@ -243,7 +243,8 @@ discard block |
||
| 243 | 243 | try { |
| 244 | 244 | $this->instance->deleteDatabase($this->getDatabaseName()); |
| 245 | 245 | $this->createDatabase(); |
| 246 | - } catch (CouchDBException $e) { |
|
| 246 | + } |
|
| 247 | + catch (CouchDBException $e) { |
|
| 247 | 248 | throw new PhpfastcacheDriverException('Got error while trying to delete and recreate the database: ' . $e->getMessage(), 0, $e); |
| 248 | 249 | } |
| 249 | 250 | |
@@ -270,8 +271,7 @@ discard block |
||
| 270 | 271 | * @return mixed |
| 271 | 272 | * @throws \Exception |
| 272 | 273 | */ |
| 273 | - protected function decode($value) |
|
| 274 | - { |
|
| 274 | + protected function decode($value) { |
|
| 275 | 275 | $value[ExtendedCacheItemPoolInterface::DRIVER_DATA_WRAPPER_INDEX] = \unserialize($value[ExtendedCacheItemPoolInterface::DRIVER_DATA_WRAPPER_INDEX], ['allowed_classes' => true]); |
| 276 | 276 | |
| 277 | 277 | $value[ExtendedCacheItemPoolInterface::DRIVER_EDATE_WRAPPER_INDEX] = new \DateTime( |
@@ -37,8 +37,7 @@ discard block |
||
| 37 | 37 | * @param $key |
| 38 | 38 | * @throws PhpfastcacheInvalidArgumentException |
| 39 | 39 | */ |
| 40 | - public function __construct(FilesDriver $driver, $key) |
|
| 41 | - { |
|
| 40 | + public function __construct(FilesDriver $driver, $key) { |
|
| 42 | 41 | $this->__BaseConstruct($driver, $key); |
| 43 | 42 | } |
| 44 | 43 | |
@@ -47,8 +46,7 @@ discard block |
||
| 47 | 46 | * @return static |
| 48 | 47 | * @throws PhpfastcacheInvalidArgumentException |
| 49 | 48 | */ |
| 50 | - public function setDriver(ExtendedCacheItemPoolInterface $driver) |
|
| 51 | - { |
|
| 49 | + public function setDriver(ExtendedCacheItemPoolInterface $driver) { |
|
| 52 | 50 | if ($driver instanceof FilesDriver) { |
| 53 | 51 | $this->driver = $driver; |
| 54 | 52 | |
@@ -47,8 +47,7 @@ discard block |
||
| 47 | 47 | * @param Config $config |
| 48 | 48 | * @param string $instanceId |
| 49 | 49 | */ |
| 50 | - public function __construct(Config $config, string $instanceId) |
|
| 51 | - { |
|
| 50 | + public function __construct(Config $config, string $instanceId) { |
|
| 52 | 51 | $this->__parentConstruct($config, $instanceId); |
| 53 | 52 | } |
| 54 | 53 | |
@@ -72,13 +71,13 @@ discard block |
||
| 72 | 71 | * @param CacheItemInterface $item |
| 73 | 72 | * @return null|array |
| 74 | 73 | */ |
| 75 | - protected function driverRead(CacheItemInterface $item) |
|
| 76 | - { |
|
| 74 | + protected function driverRead(CacheItemInterface $item) { |
|
| 77 | 75 | $file_path = $this->getFilePath($item->getKey(), true); |
| 78 | 76 | |
| 79 | 77 | try{ |
| 80 | 78 | $content = $this->readFile($file_path); |
| 81 | - }catch (PhpfastcacheIOException $e){ |
|
| 79 | + } |
|
| 80 | + catch (PhpfastcacheIOException $e){ |
|
| 82 | 81 | return null; |
| 83 | 82 | } |
| 84 | 83 | |
@@ -104,7 +103,8 @@ discard block |
||
| 104 | 103 | */ |
| 105 | 104 | try { |
| 106 | 105 | return $this->writefile($file_path, $data, $this->getConfig()->isSecureFileManipulation()); |
| 107 | - } catch (Exception $e) { |
|
| 106 | + } |
|
| 107 | + catch (Exception $e) { |
|
| 108 | 108 | return false; |
| 109 | 109 | } |
| 110 | 110 | } |
@@ -37,8 +37,7 @@ discard block |
||
| 37 | 37 | * @param $key |
| 38 | 38 | * @throws PhpfastcacheInvalidArgumentException |
| 39 | 39 | */ |
| 40 | - public function __construct(SsdbDriver $driver, $key) |
|
| 41 | - { |
|
| 40 | + public function __construct(SsdbDriver $driver, $key) { |
|
| 42 | 41 | $this->__BaseConstruct($driver, $key); |
| 43 | 42 | } |
| 44 | 43 | |
@@ -47,8 +46,7 @@ discard block |
||
| 47 | 46 | * @return static |
| 48 | 47 | * @throws PhpfastcacheInvalidArgumentException |
| 49 | 48 | */ |
| 50 | - public function setDriver(ExtendedCacheItemPoolInterface $driver) |
|
| 51 | - { |
|
| 49 | + public function setDriver(ExtendedCacheItemPoolInterface $driver) { |
|
| 52 | 50 | if ($driver instanceof SsdbDriver) { |
| 53 | 51 | $this->driver = $driver; |
| 54 | 52 | |
@@ -87,7 +87,8 @@ discard block |
||
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | return true; |
| 90 | - } catch (SSDBException $e) { |
|
| 90 | + } |
|
| 91 | + catch (SSDBException $e) { |
|
| 91 | 92 | throw new PhpfastcacheDriverCheckException('Ssdb failed to connect with error: ' . $e->getMessage(), 0, $e); |
| 92 | 93 | } |
| 93 | 94 | } |
@@ -96,8 +97,7 @@ discard block |
||
| 96 | 97 | * @param CacheItemInterface $item |
| 97 | 98 | * @return null|array |
| 98 | 99 | */ |
| 99 | - protected function driverRead(CacheItemInterface $item) |
|
| 100 | - { |
|
| 100 | + protected function driverRead(CacheItemInterface $item) { |
|
| 101 | 101 | $val = $this->instance->get($item->getEncodedKey()); |
| 102 | 102 | if ($val == false) { |
| 103 | 103 | return null; |
@@ -38,8 +38,7 @@ discard block |
||
| 38 | 38 | * @param $key |
| 39 | 39 | * @throws PhpfastcacheInvalidArgumentException |
| 40 | 40 | */ |
| 41 | - public function __construct(CassandraDriver $driver, $key) |
|
| 42 | - { |
|
| 41 | + public function __construct(CassandraDriver $driver, $key) { |
|
| 43 | 42 | $this->__BaseConstruct($driver, $key); |
| 44 | 43 | } |
| 45 | 44 | |
@@ -48,8 +47,7 @@ discard block |
||
| 48 | 47 | * @return static |
| 49 | 48 | * @throws PhpfastcacheInvalidArgumentException |
| 50 | 49 | */ |
| 51 | - public function setDriver(ExtendedCacheItemPoolInterface $driver) |
|
| 52 | - { |
|
| 50 | + public function setDriver(ExtendedCacheItemPoolInterface $driver) { |
|
| 53 | 51 | if ($driver instanceof CassandraDriver) { |
| 54 | 52 | $this->driver = $driver; |
| 55 | 53 | |