@@ -49,7 +49,7 @@ |
||
| 49 | 49 | |
| 50 | 50 | if (!$cacheItem->isHit()) { |
| 51 | 51 | $cacheItem->set($callback()); |
| 52 | - if($expiresAfter){ |
|
| 52 | + if ($expiresAfter) { |
|
| 53 | 53 | $cacheItem->expiresAfter($expiresAfter); |
| 54 | 54 | } |
| 55 | 55 | $this->cacheInstance->save($cacheItem); |
@@ -16,7 +16,7 @@ |
||
| 16 | 16 | namespace Phpfastcache\Helper; |
| 17 | 17 | |
| 18 | 18 | use Phpfastcache\{ |
| 19 | - CacheManager, Event\EventInterface, EventManager |
|
| 19 | + CacheManager, Event\EventInterface, EventManager |
|
| 20 | 20 | }; |
| 21 | 21 | use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; |
| 22 | 22 | use Phpfastcache\Entities\DriverStatistic; |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | public function __construct() |
| 41 | 41 | { |
| 42 | - $this->instances =& CacheManager::getInternalInstances(); |
|
| 42 | + $this->instances = & CacheManager::getInternalInstances(); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | /** |
@@ -47,11 +47,11 @@ discard block |
||
| 47 | 47 | */ |
| 48 | 48 | protected function getGenericCallback(): \Closure |
| 49 | 49 | { |
| 50 | - return function ($method, $args) { |
|
| 50 | + return function($method, $args) { |
|
| 51 | 51 | $return = []; |
| 52 | 52 | foreach ($this->instances as $instance) { |
| 53 | 53 | $reflectionMethod = new \ReflectionMethod(\get_class($instance), $method); |
| 54 | - $return[ $instance->getDriverName() ] = $reflectionMethod->invokeArgs($instance, $args); |
|
| 54 | + $return[$instance->getDriverName()] = $reflectionMethod->invokeArgs($instance, $args); |
|
| 55 | 55 | } |
| 56 | 56 | return $return; |
| 57 | 57 | }; |
@@ -64,32 +64,32 @@ discard block |
||
| 64 | 64 | */ |
| 65 | 65 | static $version; |
| 66 | 66 | |
| 67 | - if($version && $cacheable){ |
|
| 67 | + if ($version && $cacheable) { |
|
| 68 | 68 | return $version; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - if(\function_exists('shell_exec')){ |
|
| 71 | + if (\function_exists('shell_exec')) { |
|
| 72 | 72 | $command = 'git -C "' . __DIR__ . '" describe --abbrev=0 --tags'; |
| 73 | 73 | $stdout = shell_exec($command); |
| 74 | - if(\is_string($stdout)){ |
|
| 74 | + if (\is_string($stdout)) { |
|
| 75 | 75 | $version = \trim($stdout); |
| 76 | 76 | return $version; |
| 77 | 77 | } |
| 78 | - if(!$fallbackOnChangelog){ |
|
| 78 | + if (!$fallbackOnChangelog) { |
|
| 79 | 79 | throw new PhpfastcacheLogicException('The git command used to retrieve the PhpFastCache version has failed.'); |
| 80 | 80 | } |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - if(!$fallbackOnChangelog){ |
|
| 83 | + if (!$fallbackOnChangelog) { |
|
| 84 | 84 | throw new PhpfastcacheLogicException('shell_exec is disabled therefore the PhpFastCache version cannot be retrieved.'); |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | $changelogFilename = __DIR__ . '/../../CHANGELOG.md'; |
| 88 | - if(\file_exists($changelogFilename)){ |
|
| 88 | + if (\file_exists($changelogFilename)) { |
|
| 89 | 89 | $versionPrefix = '## '; |
| 90 | 90 | $changelog = \explode("\n", self::getPhpFastCacheChangelog()); |
| 91 | - foreach ($changelog as $line){ |
|
| 92 | - if(\strpos($line, $versionPrefix) === 0){ |
|
| 91 | + foreach ($changelog as $line) { |
|
| 92 | + if (\strpos($line, $versionPrefix) === 0) { |
|
| 93 | 93 | $version = \trim(\str_replace($versionPrefix, '', $line)); |
| 94 | 94 | return $version; |
| 95 | 95 | } |
@@ -107,13 +107,13 @@ discard block |
||
| 107 | 107 | { |
| 108 | 108 | static $hash; |
| 109 | 109 | |
| 110 | - if($hash && $cacheable){ |
|
| 110 | + if ($hash && $cacheable) { |
|
| 111 | 111 | return $hash; |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - if(\function_exists('shell_exec')){ |
|
| 114 | + if (\function_exists('shell_exec')) { |
|
| 115 | 115 | $stdout = \shell_exec('git rev-parse --short HEAD'); |
| 116 | - if(\is_string($stdout)){ |
|
| 116 | + if (\is_string($stdout)) { |
|
| 117 | 117 | $hash = \trim($stdout); |
| 118 | 118 | return "#{$hash}"; |
| 119 | 119 | } |
@@ -131,9 +131,9 @@ discard block |
||
| 131 | 131 | public static function getChangelog(): string |
| 132 | 132 | { |
| 133 | 133 | $changelogFilename = __DIR__ . '/../../CHANGELOG_API.md'; |
| 134 | - if(\file_exists($changelogFilename)){ |
|
| 134 | + if (\file_exists($changelogFilename)) { |
|
| 135 | 135 | $string = \str_replace(["\r\n", "\r"], "\n", \trim(\file_get_contents($changelogFilename))); |
| 136 | - if($string){ |
|
| 136 | + if ($string) { |
|
| 137 | 137 | return $string; |
| 138 | 138 | } |
| 139 | 139 | throw new PhpfastcacheLogicException('Unable to retrieve the PhpFastCache API changelog as it seems to be empty.'); |
@@ -150,9 +150,9 @@ discard block |
||
| 150 | 150 | public static function getPhpFastCacheChangelog(): string |
| 151 | 151 | { |
| 152 | 152 | $changelogFilename = __DIR__ . '/../../CHANGELOG.md'; |
| 153 | - if(\file_exists($changelogFilename)){ |
|
| 153 | + if (\file_exists($changelogFilename)) { |
|
| 154 | 154 | $string = \str_replace(["\r\n", "\r"], "\n", \trim(\file_get_contents($changelogFilename))); |
| 155 | - if($string){ |
|
| 155 | + if ($string) { |
|
| 156 | 156 | return $string; |
| 157 | 157 | } |
| 158 | 158 | throw new PhpfastcacheLogicException('Unable to retrieve the PhpFastCache changelog as it seems to be empty.'); |
@@ -115,10 +115,10 @@ |
||
| 115 | 115 | public function getPredisConfigArray(): array |
| 116 | 116 | { |
| 117 | 117 | return [ |
| 118 | - 'host' => $this->getHost(), |
|
| 119 | - 'port' => $this->getPort(), |
|
| 120 | - 'password' => $this->getPassword() ?: null, |
|
| 121 | - 'database' => $this->getDatabase(), |
|
| 118 | + 'host' => $this->getHost(), |
|
| 119 | + 'port' => $this->getPort(), |
|
| 120 | + 'password' => $this->getPassword() ?: null, |
|
| 121 | + 'database' => $this->getDatabase(), |
|
| 122 | 122 | ]; |
| 123 | 123 | } |
| 124 | 124 | |
@@ -17,11 +17,11 @@ discard block |
||
| 17 | 17 | |
| 18 | 18 | use CouchbaseCluster as CouchbaseClient; |
| 19 | 19 | use Phpfastcache\Core\Pool\{ |
| 20 | - DriverBaseTrait, ExtendedCacheItemPoolInterface |
|
| 20 | + DriverBaseTrait, ExtendedCacheItemPoolInterface |
|
| 21 | 21 | }; |
| 22 | 22 | use Phpfastcache\Entities\DriverStatistic; |
| 23 | 23 | use Phpfastcache\Exceptions\{ |
| 24 | - PhpfastcacheInvalidArgumentException, PhpfastcacheLogicException |
|
| 24 | + PhpfastcacheInvalidArgumentException, PhpfastcacheLogicException |
|
| 25 | 25 | }; |
| 26 | 26 | use Psr\Cache\CacheItemInterface; |
| 27 | 27 | |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | |
| 74 | 74 | $this->instance = new CouchbaseClient( |
| 75 | - 'couchbase://' . $clientConfig->getHost() . ($clientConfig->getPort() ? ":{$clientConfig->getPort()}" : '') |
|
| 75 | + 'couchbase://' . $clientConfig->getHost() . ($clientConfig->getPort() ? ":{$clientConfig->getPort()}" : '') |
|
| 76 | 76 | ); |
| 77 | 77 | |
| 78 | 78 | $this->instance->authenticate($authenticator); |
@@ -114,9 +114,9 @@ discard block |
||
| 114 | 114 | if ($item instanceof Item) { |
| 115 | 115 | try { |
| 116 | 116 | return (bool)$this->getBucket()->upsert( |
| 117 | - $item->getEncodedKey(), |
|
| 118 | - $this->encode($this->driverPreWrap($item)), |
|
| 119 | - ['expiry' => $item->getTtl()] |
|
| 117 | + $item->getEncodedKey(), |
|
| 118 | + $this->encode($this->driverPreWrap($item)), |
|
| 119 | + ['expiry' => $item->getTtl()] |
|
| 120 | 120 | ); |
| 121 | 121 | } catch (\CouchbaseException $e) { |
| 122 | 122 | return false; |
@@ -192,10 +192,10 @@ discard block |
||
| 192 | 192 | $info = $this->getBucket()->manager()->info(); |
| 193 | 193 | |
| 194 | 194 | return (new DriverStatistic()) |
| 195 | - ->setSize($info[ 'basicStats' ][ 'diskUsed' ]) |
|
| 196 | - ->setRawData($info) |
|
| 197 | - ->setData(\implode(', ', \array_keys($this->itemInstances))) |
|
| 198 | - ->setInfo('CouchBase version ' . $info[ 'nodes' ][ 0 ][ 'version' ] . ', Uptime (in days): ' . round($info[ 'nodes' ][ 0 ][ 'uptime' ] / 86400, |
|
| 199 | - 1) . "\n For more information see RawData."); |
|
| 195 | + ->setSize($info[ 'basicStats' ][ 'diskUsed' ]) |
|
| 196 | + ->setRawData($info) |
|
| 197 | + ->setData(\implode(', ', \array_keys($this->itemInstances))) |
|
| 198 | + ->setInfo('CouchBase version ' . $info[ 'nodes' ][ 0 ][ 'version' ] . ', Uptime (in days): ' . round($info[ 'nodes' ][ 0 ][ 'uptime' ] / 86400, |
|
| 199 | + 1) . "\n For more information see RawData."); |
|
| 200 | 200 | } |
| 201 | 201 | } |
| 202 | 202 | \ No newline at end of file |
@@ -78,8 +78,8 @@ discard block |
||
| 78 | 78 | $this->instance->authenticate($authenticator); |
| 79 | 79 | |
| 80 | 80 | foreach ($clientConfig->getBuckets() as $bucket) { |
| 81 | - $this->currentBucket = $this->currentBucket ?: $bucket[ 'bucket' ]; |
|
| 82 | - $this->setBucket($bucket[ 'bucket' ], $this->instance->openBucket($bucket[ 'bucket' ])); |
|
| 81 | + $this->currentBucket = $this->currentBucket ?: $bucket['bucket']; |
|
| 82 | + $this->setBucket($bucket['bucket'], $this->instance->openBucket($bucket['bucket'])); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | return true; |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | */ |
| 114 | 114 | if ($item instanceof Item) { |
| 115 | 115 | try { |
| 116 | - return (bool)$this->getBucket()->upsert( |
|
| 116 | + return (bool) $this->getBucket()->upsert( |
|
| 117 | 117 | $item->getEncodedKey(), |
| 118 | 118 | $this->encode($this->driverPreWrap($item)), |
| 119 | 119 | ['expiry' => $item->getTtl()] |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | */ |
| 139 | 139 | if ($item instanceof Item) { |
| 140 | 140 | try { |
| 141 | - return (bool)$this->getBucket()->remove($item->getEncodedKey()); |
|
| 141 | + return (bool) $this->getBucket()->remove($item->getEncodedKey()); |
|
| 142 | 142 | } catch (\Couchbase\Exception $e) { |
| 143 | 143 | return $e->getCode() === COUCHBASE_KEY_ENOENT; |
| 144 | 144 | } |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | */ |
| 162 | 162 | protected function getBucket(): \CouchbaseBucket |
| 163 | 163 | { |
| 164 | - return $this->bucketInstances[ $this->currentBucket ]; |
|
| 164 | + return $this->bucketInstances[$this->currentBucket]; |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | /** |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | protected function setBucket($bucketName, \CouchbaseBucket $CouchbaseBucket) |
| 173 | 173 | { |
| 174 | 174 | if (!\array_key_exists($bucketName, $this->bucketInstances)) { |
| 175 | - $this->bucketInstances[ $bucketName ] = $CouchbaseBucket; |
|
| 175 | + $this->bucketInstances[$bucketName] = $CouchbaseBucket; |
|
| 176 | 176 | } else { |
| 177 | 177 | throw new PhpfastcacheLogicException('A bucket instance with this name already exists.'); |
| 178 | 178 | } |
@@ -192,10 +192,10 @@ discard block |
||
| 192 | 192 | $info = $this->getBucket()->manager()->info(); |
| 193 | 193 | |
| 194 | 194 | return (new DriverStatistic()) |
| 195 | - ->setSize($info[ 'basicStats' ][ 'diskUsed' ]) |
|
| 195 | + ->setSize($info['basicStats']['diskUsed']) |
|
| 196 | 196 | ->setRawData($info) |
| 197 | 197 | ->setData(\implode(', ', \array_keys($this->itemInstances))) |
| 198 | - ->setInfo('CouchBase version ' . $info[ 'nodes' ][ 0 ][ 'version' ] . ', Uptime (in days): ' . round($info[ 'nodes' ][ 0 ][ 'uptime' ] / 86400, |
|
| 198 | + ->setInfo('CouchBase version ' . $info['nodes'][0]['version'] . ', Uptime (in days): ' . round($info['nodes'][0]['uptime'] / 86400, |
|
| 199 | 199 | 1) . "\n For more information see RawData."); |
| 200 | 200 | } |
| 201 | 201 | } |
| 202 | 202 | \ No newline at end of file |