Completed
Push — master ( 5c1276...fd0d63 )
by smiley
03:05
created
src/Drivers/APCUDriver.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,10 +12,10 @@
 block discarded – undo
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;
Please login to merge, or discard this patch.
src/Drivers/MemoryCacheDriver.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Drivers/RedisDriver.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 use chillerlan\Traits\ImmutableSettingsInterface;
16 16
 use Redis;
17 17
 
18
-class RedisDriver extends CacheDriverAbstract{
18
+class RedisDriver extends CacheDriverAbstract {
19 19
 
20 20
 	/**
21 21
 	 * @var \Redis
@@ -28,14 +28,14 @@  discard block
 block discarded – undo
28 28
 	 * @param \Redis                                             $redis
29 29
 	 * @param \chillerlan\Traits\ImmutableSettingsInterface|null $options
30 30
 	 */
31
-	public function __construct(Redis $redis, ImmutableSettingsInterface $options = null){
31
+	public function __construct(Redis $redis, ImmutableSettingsInterface $options = null) {
32 32
 		parent::__construct($options);
33 33
 
34 34
 		$this->redis = $redis;
35 35
 	}
36 36
 
37 37
 	/** @inheritdoc */
38
-	public function get(string $key, $default = null){
38
+	public function get(string $key, $default = null) {
39 39
 		$value = $this->redis->get($key);
40 40
 
41 41
 		return $value ? $value : $default;
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	/** @inheritdoc */
45 45
 	public function set(string $key, $value, int $ttl = null):bool{
46 46
 
47
-		if($ttl === null){
47
+		if ($ttl === null) {
48 48
 			return $this->redis->set($key, $value);
49 49
 		}
50 50
 
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 
69 69
 		$return = [];
70 70
 
71
-		foreach($keys as $key){
71
+		foreach ($keys as $key) {
72 72
 			$return[$key] = $values[$key] !== false ? $values[$key] : $default;
73 73
 		}
74 74
 
@@ -78,13 +78,13 @@  discard block
 block discarded – undo
78 78
 	/** @inheritdoc */
79 79
 	public function setMultiple(array $values, int $ttl = null):bool{
80 80
 
81
-		if($ttl === null){
81
+		if ($ttl === null) {
82 82
 			return $this->redis->msetnx($values);
83 83
 		}
84 84
 
85 85
 		$return = [];
86 86
 
87
-		foreach($values as $key => $value){
87
+		foreach ($values as $key => $value) {
88 88
 			$return[] = $this->set($key, $value, $ttl);
89 89
 		}
90 90
 
Please login to merge, or discard this patch.
src/Drivers/MemcachedDriver.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 use chillerlan\Traits\ImmutableSettingsInterface;
17 17
 use Memcached;
18 18
 
19
-class MemcachedDriver extends CacheDriverAbstract{
19
+class MemcachedDriver extends CacheDriverAbstract {
20 20
 
21 21
 	/**
22 22
 	 * @var \Memcached
@@ -31,12 +31,12 @@  discard block
 block discarded – undo
31 31
 	 *
32 32
 	 * @throws \chillerlan\SimpleCache\CacheException
33 33
 	 */
34
-	public function __construct(Memcached $memcached, ImmutableSettingsInterface $options = null){
34
+	public function __construct(Memcached $memcached, ImmutableSettingsInterface $options = null) {
35 35
 		parent::__construct($options);
36 36
 
37 37
 		$this->memcached = $memcached;
38 38
 
39
-		if(empty($this->memcached->getServerList())){
39
+		if (empty($this->memcached->getServerList())) {
40 40
 			$msg = 'no memcache server available';
41 41
 
42 42
 			$this->logger->error($msg);
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	}
47 47
 
48 48
 	/** @inheritdoc */
49
-	public function get(string $key, $default = null){
49
+	public function get(string $key, $default = null) {
50 50
 		$value = $this->memcached->get($key);
51 51
 
52 52
 		return $value ?: $default;
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 		$values = $this->memcached->getMulti($keys);
73 73
 		$return = [];
74 74
 
75
-		foreach($keys as $key){
75
+		foreach ($keys as $key) {
76 76
 			$return[$key] = $values[$key] ?? $default;
77 77
 		}
78 78
 
Please login to merge, or discard this patch.
src/Drivers/CacheDriverInterface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
 /**
16 16
  * @method setLogger(\Psr\Log\LoggerInterface $logger)
17 17
  */
18
-interface CacheDriverInterface{
18
+interface CacheDriverInterface {
19 19
 
20 20
 	/**
21 21
 	 * @param string     $key
Please login to merge, or discard this patch.
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/Cache.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	 * @param \chillerlan\SimpleCache\Drivers\CacheDriverInterface $cacheDriver
38 38
 	 * @param \Psr\Log\LoggerInterface                             $logger
39 39
 	 */
40
-	public function __construct(CacheDriverInterface $cacheDriver, LoggerInterface $logger = null){
40
+	public function __construct(CacheDriverInterface $cacheDriver, LoggerInterface $logger = null) {
41 41
 		$this->cacheDriver = $cacheDriver;
42 42
 		$this->setLogger($logger ?? new NullLogger);
43 43
 	}
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	}
56 56
 
57 57
 	/** @inheritdoc */
58
-	public function get($key, $default = null){
58
+	public function get($key, $default = null) {
59 59
 		$this->checkKey($key);
60 60
 
61 61
 		return $this->cacheDriver->get($key, $default);
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 	public function setMultiple($values, $ttl = null):bool{
93 93
 		$values = $this->getData($values);
94 94
 
95
-		foreach($values as $key => $value){
95
+		foreach ($values as $key => $value) {
96 96
 			$this->checkKey($key);
97 97
 		}
98 98
 
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 	 */
123 123
 	protected function checkKey($key):void{
124 124
 
125
-		if(!is_string($key) || empty($key)){
125
+		if (!is_string($key) || empty($key)) {
126 126
 			$msg = 'invalid cache key: "'.$key.'"';
127 127
 			$this->logger->error($msg);
128 128
 
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 	 */
139 139
 	protected function checkKeyArray(array $keys):void{
140 140
 
141
-		foreach($keys as $key){
141
+		foreach ($keys as $key) {
142 142
 			$this->checkKey($key);
143 143
 		}
144 144
 
@@ -152,10 +152,10 @@  discard block
 block discarded – undo
152 152
 	 */
153 153
 	protected function getData($data):array{
154 154
 
155
-		if($data instanceof Traversable){
155
+		if ($data instanceof Traversable) {
156 156
 			return iterator_to_array($data); // @codeCoverageIgnore
157 157
 		}
158
-		else if(is_array($data)){
158
+		else if (is_array($data)) {
159 159
 			return $data;
160 160
 		}
161 161
 
@@ -171,12 +171,12 @@  discard block
 block discarded – undo
171 171
 	 * @return int|null
172 172
 	 * @throws \chillerlan\SimpleCache\InvalidArgumentException
173 173
 	 */
174
-	protected function getTTL($ttl):?int{
174
+	protected function getTTL($ttl): ?int{
175 175
 
176
-		if($ttl instanceof DateInterval){
176
+		if ($ttl instanceof DateInterval) {
177 177
 			return (new DateTime('now'))->add($ttl)->getTimeStamp() - time();
178 178
 		}
179
-		else if(is_int($ttl) || $ttl === null){
179
+		else if (is_int($ttl) || $ttl === null) {
180 180
 			return $ttl;
181 181
 		}
182 182
 
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 	 *
192 192
 	 * @throws \chillerlan\SimpleCache\CacheException
193 193
 	 */
194
-	protected function throwException(string $message){
194
+	protected function throwException(string $message) {
195 195
 		$this->logger->error($message);
196 196
 
197 197
 		throw new InvalidArgumentException($message);
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -154,8 +154,7 @@  discard block
 block discarded – undo
154 154
 
155 155
 		if($data instanceof Traversable){
156 156
 			return iterator_to_array($data); // @codeCoverageIgnore
157
-		}
158
-		else if(is_array($data)){
157
+		} else if(is_array($data)){
159 158
 			return $data;
160 159
 		}
161 160
 
@@ -175,8 +174,7 @@  discard block
 block discarded – undo
175 174
 
176 175
 		if($ttl instanceof DateInterval){
177 176
 			return (new DateTime('now'))->add($ttl)->getTimeStamp() - time();
178
-		}
179
-		else if(is_int($ttl) || $ttl === null){
177
+		} else if(is_int($ttl) || $ttl === null){
180 178
 			return $ttl;
181 179
 		}
182 180
 
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/CacheOptionsTrait.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,9 +12,9 @@
 block discarded – undo
12 12
 
13 13
 namespace chillerlan\SimpleCache;
14 14
 
15
-trait CacheOptionsTrait{
15
+trait CacheOptionsTrait {
16 16
 
17 17
 	protected $cacheFilestorage = '';
18
-	protected $cacheSessionkey    = '_session_cache';
18
+	protected $cacheSessionkey = '_session_cache';
19 19
 
20 20
 }
Please login to merge, or discard this patch.