@@ -14,4 +14,4 @@ |
||
| 14 | 14 | |
| 15 | 15 | use \Psr\SimpleCache\InvalidArgumentException; |
| 16 | 16 | |
| 17 | -class SimpleCacheInvalidArgumentException extends SimpleCacheException implements InvalidArgumentException{} |
|
| 17 | +class SimpleCacheInvalidArgumentException extends SimpleCacheException implements InvalidArgumentException {} |
|
@@ -14,4 +14,4 @@ |
||
| 14 | 14 | |
| 15 | 15 | use Psr\SimpleCache\CacheException; |
| 16 | 16 | |
| 17 | -class SimpleCacheException extends \Exception implements CacheException{} |
|
| 17 | +class SimpleCacheException extends \Exception implements CacheException {} |
|
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | |
| 15 | 15 | use Redis; |
| 16 | 16 | |
| 17 | -class RedisDriver extends CacheDriverAbstract{ |
|
| 17 | +class RedisDriver extends CacheDriverAbstract { |
|
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * @var \Redis |
@@ -26,12 +26,12 @@ discard block |
||
| 26 | 26 | * |
| 27 | 27 | * @param \Redis $redis |
| 28 | 28 | */ |
| 29 | - public function __construct(Redis $redis){ |
|
| 29 | + public function __construct(Redis $redis) { |
|
| 30 | 30 | $this->redis = $redis; |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | /** @inheritdoc */ |
| 34 | - public function get(string $key, $default = null){ |
|
| 34 | + public function get(string $key, $default = null) { |
|
| 35 | 35 | $value = $this->redis->get($key); |
| 36 | 36 | |
| 37 | 37 | return $value ? $value : $default; |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | /** @inheritdoc */ |
| 41 | 41 | public function set(string $key, $value, int $ttl = null):bool{ |
| 42 | 42 | |
| 43 | - if(is_null($ttl)){ |
|
| 43 | + if (is_null($ttl)) { |
|
| 44 | 44 | return $this->redis->set($key, $value); |
| 45 | 45 | } |
| 46 | 46 | |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | $return = []; |
| 66 | 66 | |
| 67 | - foreach($keys as $key){ |
|
| 67 | + foreach ($keys as $key) { |
|
| 68 | 68 | $return[$key] = $values[$key] !== false ? $values[$key] : $default; |
| 69 | 69 | } |
| 70 | 70 | |
@@ -74,13 +74,13 @@ discard block |
||
| 74 | 74 | /** @inheritdoc */ |
| 75 | 75 | public function setMultiple(array $values, int $ttl = null):bool{ |
| 76 | 76 | |
| 77 | - if(is_null($ttl)){ |
|
| 77 | + if (is_null($ttl)) { |
|
| 78 | 78 | return $this->redis->msetnx($values); |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | $return = []; |
| 82 | 82 | |
| 83 | - foreach($values as $key => $value){ |
|
| 83 | + foreach ($values as $key => $value) { |
|
| 84 | 84 | $return[] = $this->set($key, $value, $ttl); |
| 85 | 85 | } |
| 86 | 86 | |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | namespace chillerlan\SimpleCache\Drivers; |
| 14 | 14 | |
| 15 | -abstract class CacheDriverAbstract implements CacheDriverInterface{ |
|
| 15 | +abstract class CacheDriverAbstract implements CacheDriverInterface { |
|
| 16 | 16 | |
| 17 | 17 | /** @inheritdoc */ |
| 18 | 18 | public function has(string $key):bool{ |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | public function getMultiple(array $keys, $default = null):array{ |
| 24 | 24 | $data = []; |
| 25 | 25 | |
| 26 | - foreach($keys as $key){ |
|
| 26 | + foreach ($keys as $key) { |
|
| 27 | 27 | $data[$key] = $this->get($key, $default); |
| 28 | 28 | } |
| 29 | 29 | |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | public function setMultiple(array $values, int $ttl = null):bool{ |
| 35 | 35 | $return = []; |
| 36 | 36 | |
| 37 | - foreach($values as $key => $value){ |
|
| 37 | + foreach ($values as $key => $value) { |
|
| 38 | 38 | $return[] = $this->set($key, $value, $ttl); |
| 39 | 39 | } |
| 40 | 40 | |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | public function deleteMultiple(array $keys):bool{ |
| 46 | 46 | $return = []; |
| 47 | 47 | |
| 48 | - foreach($keys as $key){ |
|
| 48 | + foreach ($keys as $key) { |
|
| 49 | 49 | $return[] = $this->delete($key); |
| 50 | 50 | } |
| 51 | 51 | |
@@ -59,9 +59,9 @@ discard block |
||
| 59 | 59 | */ |
| 60 | 60 | protected function checkReturn(array $booleans):bool{ |
| 61 | 61 | |
| 62 | - foreach($booleans as $bool){ |
|
| 62 | + foreach ($booleans as $bool) { |
|
| 63 | 63 | |
| 64 | - if(!(bool)$bool){ |
|
| 64 | + if (!(bool)$bool) { |
|
| 65 | 65 | return false; // @codeCoverageIgnore |
| 66 | 66 | } |
| 67 | 67 | |
@@ -12,10 +12,10 @@ |
||
| 12 | 12 | |
| 13 | 13 | namespace chillerlan\SimpleCache\Drivers; |
| 14 | 14 | |
| 15 | -class APCUDriver extends CacheDriverAbstract{ |
|
| 15 | +class APCUDriver extends CacheDriverAbstract { |
|
| 16 | 16 | |
| 17 | 17 | /** @inheritdoc */ |
| 18 | - public function get(string $key, $default = null){ |
|
| 18 | + public function get(string $key, $default = null) { |
|
| 19 | 19 | $value = apcu_fetch($key); |
| 20 | 20 | |
| 21 | 21 | return $value ?: $default; |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | use chillerlan\SimpleCache\SimpleCacheException; |
| 16 | 16 | use Memcached; |
| 17 | 17 | |
| 18 | -class MemcachedDriver extends CacheDriverAbstract{ |
|
| 18 | +class MemcachedDriver extends CacheDriverAbstract { |
|
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | 21 | * @var \Memcached |
@@ -29,17 +29,17 @@ discard block |
||
| 29 | 29 | * |
| 30 | 30 | * @throws \chillerlan\SimpleCache\SimpleCacheException |
| 31 | 31 | */ |
| 32 | - public function __construct(Memcached $memcached){ |
|
| 32 | + public function __construct(Memcached $memcached) { |
|
| 33 | 33 | $this->memcached = $memcached; |
| 34 | 34 | |
| 35 | - if(empty($this->memcached->getServerList())){ |
|
| 35 | + if (empty($this->memcached->getServerList())) { |
|
| 36 | 36 | throw new SimpleCacheException('no memcache server available'); |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** @inheritdoc */ |
| 42 | - public function get(string $key, $default = null){ |
|
| 42 | + public function get(string $key, $default = null) { |
|
| 43 | 43 | $value = $this->memcached->get($key); |
| 44 | 44 | |
| 45 | 45 | return $value ?: $default; |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | $values = $this->memcached->getMulti($keys); |
| 66 | 66 | $return = []; |
| 67 | 67 | |
| 68 | - foreach($keys as $key){ |
|
| 68 | + foreach ($keys as $key) { |
|
| 69 | 69 | $return[$key] = $values[$key] ?? $default; |
| 70 | 70 | } |
| 71 | 71 | |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | namespace chillerlan\SimpleCache\Drivers; |
| 14 | 14 | |
| 15 | -class SessionCacheDriver extends CacheDriverAbstract{ |
|
| 15 | +class SessionCacheDriver extends CacheDriverAbstract { |
|
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | 18 | * @var string |
@@ -24,18 +24,18 @@ discard block |
||
| 24 | 24 | * |
| 25 | 25 | * @param string|null $key |
| 26 | 26 | */ |
| 27 | - public function __construct(string $key = null){ |
|
| 27 | + public function __construct(string $key = null) { |
|
| 28 | 28 | $this->key = $key ?? '_session_cache'; |
| 29 | 29 | |
| 30 | 30 | $_SESSION[$this->key] = []; |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | /** @inheritdoc */ |
| 34 | - public function get(string $key, $default = null){ |
|
| 34 | + public function get(string $key, $default = null) { |
|
| 35 | 35 | |
| 36 | - if(isset($_SESSION[$this->key][$key])){ |
|
| 36 | + if (isset($_SESSION[$this->key][$key])) { |
|
| 37 | 37 | |
| 38 | - if($_SESSION[$this->key][$key]['ttl'] === null || $_SESSION[$this->key][$key]['ttl'] > time()){ |
|
| 38 | + if ($_SESSION[$this->key][$key]['ttl'] === null || $_SESSION[$this->key][$key]['ttl'] > time()) { |
|
| 39 | 39 | return $_SESSION[$this->key][$key]['content']; |
| 40 | 40 | } |
| 41 | 41 | |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | namespace chillerlan\SimpleCache\Drivers; |
| 14 | 14 | |
| 15 | -class MemoryCacheDriver extends CacheDriverAbstract{ |
|
| 15 | +class MemoryCacheDriver extends CacheDriverAbstract { |
|
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | 18 | * @var array |
@@ -20,11 +20,11 @@ discard block |
||
| 20 | 20 | protected $cache = []; |
| 21 | 21 | |
| 22 | 22 | /** @inheritdoc */ |
| 23 | - public function get(string $key, $default = null){ |
|
| 23 | + public function get(string $key, $default = null) { |
|
| 24 | 24 | |
| 25 | - if(isset($this->cache[$key])){ |
|
| 25 | + if (isset($this->cache[$key])) { |
|
| 26 | 26 | |
| 27 | - if($this->cache[$key]['ttl'] === null || $this->cache[$key]['ttl'] > time()){ |
|
| 27 | + if ($this->cache[$key]['ttl'] === null || $this->cache[$key]['ttl'] > time()) { |
|
| 28 | 28 | return $this->cache[$key]['content']; |
| 29 | 29 | } |
| 30 | 30 | |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | |
| 13 | 13 | namespace chillerlan\SimpleCache\Drivers; |
| 14 | 14 | |
| 15 | -interface CacheDriverInterface{ |
|
| 15 | +interface CacheDriverInterface { |
|
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | 18 | * @param string $key |