Passed
Push — main ( 25c1e9...89dc88 )
by smiley
01:35
created
src/CacheException.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,4 +12,4 @@
 block discarded – undo
12 12
 
13 13
 namespace chillerlan\SimpleCache;
14 14
 
15
-class CacheException extends \Exception implements \Psr\SimpleCache\CacheException{}
15
+class CacheException extends \Exception implements \Psr\SimpleCache\CacheException {}
Please login to merge, or discard this patch.
src/InvalidArgumentException.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,4 +12,4 @@
 block discarded – undo
12 12
 
13 13
 namespace chillerlan\SimpleCache;
14 14
 
15
-class InvalidArgumentException extends CacheException implements \Psr\SimpleCache\InvalidArgumentException{}
15
+class InvalidArgumentException extends CacheException implements \Psr\SimpleCache\InvalidArgumentException {}
Please login to merge, or discard this patch.
src/CacheOptions.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,6 +18,6 @@
 block discarded – undo
18 18
  * @property string $cacheFilestorage
19 19
  * @property string $cacheSessionkey
20 20
  */
21
-class CacheOptions extends SettingsContainerAbstract{
21
+class CacheOptions extends SettingsContainerAbstract {
22 22
 	use CacheOptionsTrait;
23 23
 }
Please login to merge, or discard this patch.
src/CacheOptionsTrait.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
 
13 13
 namespace chillerlan\SimpleCache;
14 14
 
15
-trait CacheOptionsTrait{
15
+trait CacheOptionsTrait {
16 16
 
17 17
 	protected string $cacheFilestorage = '';
18 18
 	protected string $cacheSessionkey  = '_session_cache';
Please login to merge, or discard this patch.
src/FileCache.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 
22 22
 use const DIRECTORY_SEPARATOR;
23 23
 
24
-class FileCache extends CacheDriverAbstract{
24
+class FileCache extends CacheDriverAbstract {
25 25
 
26 26
 	protected string $cachedir;
27 27
 
@@ -33,32 +33,32 @@  discard block
 block discarded – undo
33 33
 	 *
34 34
 	 * @throws \chillerlan\SimpleCache\CacheException
35 35
 	 */
36
-	public function __construct(SettingsContainerInterface $options = null, LoggerInterface $logger = null){
36
+	public function __construct(SettingsContainerInterface $options = null, LoggerInterface $logger = null) {
37 37
 		parent::__construct($options, $logger);
38 38
 
39 39
 		$this->cachedir = rtrim($this->options->cacheFilestorage, '/\\').DIRECTORY_SEPARATOR;
40 40
 
41
-		if(!is_dir($this->cachedir)){
41
+		if (!is_dir($this->cachedir)) {
42 42
 			throw new CacheException('invalid cachedir "'.$this->cachedir.'"');
43 43
 		}
44 44
 
45
-		if(!is_writable($this->cachedir)){
45
+		if (!is_writable($this->cachedir)) {
46 46
 			throw new CacheException('cachedir is read-only. permissions?');
47 47
 		}
48 48
 
49 49
 	}
50 50
 
51 51
 	/** @inheritdoc */
52
-	public function get($key, $default = null){
52
+	public function get($key, $default = null) {
53 53
 		$filename = $this->getFilepath($this->checkKey($key));
54 54
 
55
-		if(is_file($filename)){
55
+		if (is_file($filename)) {
56 56
 			$content = file_get_contents($filename);
57 57
 
58
-			if(!empty($content)){
58
+			if (!empty($content)) {
59 59
 				$data = unserialize($content);
60 60
 
61
-				if($data->ttl === null || $data->ttl > time()){
61
+				if ($data->ttl === null || $data->ttl > time()) {
62 62
 					return $data->content;
63 63
 				}
64 64
 
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 		$file = $this->getFilepath($this->checkKey($key));
78 78
 		$dir  = dirname($file);
79 79
 
80
-		if(!is_dir($dir)){
80
+		if (!is_dir($dir)) {
81 81
 			mkdir($dir, 0755, true);
82 82
 		}
83 83
 
@@ -85,13 +85,13 @@  discard block
 block discarded – undo
85 85
 		$data->ttl     = null;
86 86
 		$data->content = $value;
87 87
 
88
-		if($ttl !== null){
88
+		if ($ttl !== null) {
89 89
 			$data->ttl = time() + $ttl;
90 90
 		}
91 91
 
92 92
 		file_put_contents($file, serialize($data));
93 93
 
94
-		if(is_file($file)){
94
+		if (is_file($file)) {
95 95
 			return true;
96 96
 		}
97 97
 
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 	public function delete($key):bool{
103 103
 		$filename = $this->getFilepath($this->checkKey($key));
104 104
 
105
-		if(is_file($filename)){
105
+		if (is_file($filename)) {
106 106
 			return unlink($filename);
107 107
 		}
108 108
 
@@ -111,13 +111,13 @@  discard block
 block discarded – undo
111 111
 
112 112
 	/** @inheritdoc */
113 113
 	public function clear():bool{
114
-		$iterator = new RecursiveDirectoryIterator($this->cachedir, FilesystemIterator::CURRENT_AS_PATHNAME|FilesystemIterator::SKIP_DOTS);
114
+		$iterator = new RecursiveDirectoryIterator($this->cachedir, FilesystemIterator::CURRENT_AS_PATHNAME | FilesystemIterator::SKIP_DOTS);
115 115
 		$return   = [];
116 116
 
117
-		foreach(new RecursiveIteratorIterator($iterator) as $path){
117
+		foreach (new RecursiveIteratorIterator($iterator) as $path) {
118 118
 
119 119
 			// skip files in the parent directory - cache files are only under /a/ab/[hash]
120
-			if(strpos(str_replace($this->cachedir, '', $path), DIRECTORY_SEPARATOR) === false){
120
+			if (strpos(str_replace($this->cachedir, '', $path), DIRECTORY_SEPARATOR) === false) {
121 121
 				continue;
122 122
 			}
123 123
 
Please login to merge, or discard this patch.
src/MemcachedCache.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 
22 22
 use function array_keys;
23 23
 
24
-class MemcachedCache extends CacheDriverAbstract{
24
+class MemcachedCache extends CacheDriverAbstract {
25 25
 
26 26
 	protected Memcached $memcached;
27 27
 
@@ -34,22 +34,22 @@  discard block
 block discarded – undo
34 34
 	 *
35 35
 	 * @throws \chillerlan\SimpleCache\CacheException
36 36
 	 */
37
-	public function __construct(Memcached $memcached, SettingsContainerInterface $options = null, LoggerInterface $logger = null){
37
+	public function __construct(Memcached $memcached, SettingsContainerInterface $options = null, LoggerInterface $logger = null) {
38 38
 		parent::__construct($options, $logger);
39 39
 
40 40
 		$this->memcached = $memcached;
41 41
 
42
-		if(empty($this->memcached->getServerList())){
42
+		if (empty($this->memcached->getServerList())) {
43 43
 			throw new CacheException('no memcache server available');
44 44
 		}
45 45
 
46 46
 	}
47 47
 
48 48
 	/** @inheritdoc */
49
-	public function get($key, $default = null){
49
+	public function get($key, $default = null) {
50 50
 		$value = $this->memcached->get($this->checkKey($key));
51 51
 
52
-		if($value !== false){
52
+		if ($value !== false) {
53 53
 			return $value;
54 54
 		}
55 55
 
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 		$values = $this->memcached->getMulti($keys);
81 81
 		$return = [];
82 82
 
83
-		foreach($keys as $key){
83
+		foreach ($keys as $key) {
84 84
 			$return[$key] = $values[$key] ?? $default;
85 85
 		}
86 86
 
Please login to merge, or discard this patch.
src/SessionCache.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 
18 18
 use function time;
19 19
 
20
-class SessionCache extends CacheDriverAbstract{
20
+class SessionCache extends CacheDriverAbstract {
21 21
 
22 22
 	protected string $key;
23 23
 
@@ -26,12 +26,12 @@  discard block
 block discarded – undo
26 26
 	 *
27 27
 	 * @throws \Psr\SimpleCache\CacheException
28 28
 	 */
29
-	public function __construct(SettingsContainerInterface $options = null, LoggerInterface $logger = null){
29
+	public function __construct(SettingsContainerInterface $options = null, LoggerInterface $logger = null) {
30 30
 		parent::__construct($options, $logger);
31 31
 
32 32
 		$this->key = $this->options->cacheSessionkey;
33 33
 
34
-		if(!is_string($this->key) || empty($this->key)){
34
+		if (!is_string($this->key) || empty($this->key)) {
35 35
 			throw new CacheException('invalid session cache key');
36 36
 		}
37 37
 
@@ -40,12 +40,12 @@  discard block
 block discarded – undo
40 40
 	}
41 41
 
42 42
 	/** @inheritdoc */
43
-	public function get($key, $default = null){
43
+	public function get($key, $default = null) {
44 44
 		$key = $this->checkKey($key);
45 45
 
46
-		if(isset($_SESSION[$this->key][$key])){
46
+		if (isset($_SESSION[$this->key][$key])) {
47 47
 
48
-			if($_SESSION[$this->key][$key]['ttl'] === null || $_SESSION[$this->key][$key]['ttl'] > time()){
48
+			if ($_SESSION[$this->key][$key]['ttl'] === null || $_SESSION[$this->key][$key]['ttl'] > time()) {
49 49
 				return $_SESSION[$this->key][$key]['content'];
50 50
 			}
51 51
 
Please login to merge, or discard this patch.
src/MemoryCache.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -14,17 +14,17 @@
 block discarded – undo
14 14
 
15 15
 use function time;
16 16
 
17
-class MemoryCache extends CacheDriverAbstract{
17
+class MemoryCache extends CacheDriverAbstract {
18 18
 
19 19
 	protected array $cache = [];
20 20
 
21 21
 	/** @inheritdoc */
22
-	public function get($key, $default = null){
22
+	public function get($key, $default = null) {
23 23
 		$key = $this->checkKey($key);
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
 
Please login to merge, or discard this patch.
src/RedisCache.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -21,24 +21,24 @@  discard block
 block discarded – undo
21 21
 
22 22
 use function array_combine, array_keys;
23 23
 
24
-class RedisCache extends CacheDriverAbstract{
24
+class RedisCache extends CacheDriverAbstract {
25 25
 
26 26
 	protected Redis $redis;
27 27
 
28 28
 	/**
29 29
 	 * RedisCache constructor.
30 30
 	 */
31
-	public function __construct(Redis $redis, SettingsContainerInterface $options = null, LoggerInterface $logger = null){
31
+	public function __construct(Redis $redis, SettingsContainerInterface $options = null, LoggerInterface $logger = null) {
32 32
 		parent::__construct($options, $logger);
33 33
 
34 34
 		$this->redis = $redis;
35 35
 	}
36 36
 
37 37
 	/** @inheritdoc */
38
-	public function get($key, $default = null){
38
+	public function get($key, $default = null) {
39 39
 		$value = $this->redis->get($this->checkKey($key));
40 40
 
41
-		if($value !== false){
41
+		if ($value !== false) {
42 42
 			return $value;
43 43
 		}
44 44
 
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 		$key = $this->checkKey($key);
51 51
 		$ttl = $this->getTTL($ttl);
52 52
 
53
-		if($ttl === null){
53
+		if ($ttl === null) {
54 54
 			return $this->redis->set($key, $value);
55 55
 		}
56 56
 
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 		$values = array_combine($keys, $this->redis->mget($keys));
78 78
 		$return = [];
79 79
 
80
-		foreach($keys as $key){
80
+		foreach ($keys as $key) {
81 81
 			/** @phan-suppress-next-line PhanTypeArraySuspiciousNullable */
82 82
 			$return[$key] = $values[$key] !== false ? $values[$key] : $default;
83 83
 		}
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 		$values = $this->getData($values);
91 91
 		$ttl    = $this->getTTL($ttl);
92 92
 
93
-		if($ttl === null){
93
+		if ($ttl === null) {
94 94
 			$this->checkKeyArray(array_keys($values));
95 95
 
96 96
 			return $this->redis->msetnx($values);
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 
99 99
 		$return = [];
100 100
 
101
-		foreach($values as $key => $value){
101
+		foreach ($values as $key => $value) {
102 102
 			$return[] = $this->set($key, $value, $ttl);
103 103
 		}
104 104
 
Please login to merge, or discard this patch.