@@ -111,10 +111,10 @@ discard block |
||
| 111 | 111 | * |
| 112 | 112 | * @return int|bool |
| 113 | 113 | */ |
| 114 | - public function increment(string $key, mixed $value = 1): int|bool |
|
| 114 | + public function increment(string $key, mixed $value = 1): int | bool |
|
| 115 | 115 | { |
| 116 | 116 | if ( ! is_null($existing = $this->get($key))) { |
| 117 | - return take(((int) $existing) + $value, function ($incremented) use ($key) { |
|
| 117 | + return take(((int) $existing) + $value, function($incremented) use ($key) { |
|
| 118 | 118 | $value = $this->serialized ? serialize($incremented) : $incremented; |
| 119 | 119 | |
| 120 | 120 | $this->storage[$key]['value'] = $value; |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | * |
| 135 | 135 | * @return int|bool |
| 136 | 136 | */ |
| 137 | - public function decrement(string $key, mixed $value = 1): int|bool |
|
| 137 | + public function decrement(string $key, mixed $value = 1): int | bool |
|
| 138 | 138 | { |
| 139 | 139 | return $this->increment($key, $value * -1); |
| 140 | 140 | } |
@@ -69,7 +69,9 @@ |
||
| 69 | 69 | */ |
| 70 | 70 | public function get(string $key) |
| 71 | 71 | { |
| 72 | - if ( ! isset($this->storage[$key])) return; |
|
| 72 | + if ( ! isset($this->storage[$key])) { |
|
| 73 | + return; |
|
| 74 | + } |
|
| 73 | 75 | |
| 74 | 76 | $item = $this->storage[$key]; |
| 75 | 77 | |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | |
| 70 | 70 | $this->memcached = $memcached; |
| 71 | 71 | $this->onVersion = (new ReflectionMethod('Memcached', 'getMulti')) |
| 72 | - ->getNumberOfParameters() == 2; |
|
| 72 | + ->getNumberOfParameters() == 2; |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /** |
@@ -201,13 +201,13 @@ discard block |
||
| 201 | 201 | return $this->memcached->decrement($this->prefix.$key, $value = 1); |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | - /** |
|
| 205 | - * Deletes a specific item from the cache store. |
|
| 206 | - * |
|
| 207 | - * @param string $key |
|
| 208 | - * |
|
| 209 | - * @return mixed |
|
| 210 | - */ |
|
| 204 | + /** |
|
| 205 | + * Deletes a specific item from the cache store. |
|
| 206 | + * |
|
| 207 | + * @param string $key |
|
| 208 | + * |
|
| 209 | + * @return mixed |
|
| 210 | + */ |
|
| 211 | 211 | public function delete(string $key): mixed |
| 212 | 212 | { |
| 213 | 213 | return $this->memcached->delete($this->prefix.$key); |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | */ |
| 110 | 110 | public function many(array $keys): array |
| 111 | 111 | { |
| 112 | - $prefixed = array_map(function ($key) { |
|
| 112 | + $prefixed = array_map(function($key) { |
|
| 113 | 113 | return $this->prefix.$key; |
| 114 | 114 | }, $keys); |
| 115 | 115 | |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | * |
| 184 | 184 | * @return int|bool |
| 185 | 185 | */ |
| 186 | - public function increment(string $key, mixed $value = 1): int|bool |
|
| 186 | + public function increment(string $key, mixed $value = 1): int | bool |
|
| 187 | 187 | { |
| 188 | 188 | return $this->memcached->increment($this->prefix.$key, $value); |
| 189 | 189 | } |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | * |
| 197 | 197 | * @return int|bool |
| 198 | 198 | */ |
| 199 | - public function decrement(string $key, mixed $value = 1): int|bool |
|
| 199 | + public function decrement(string $key, mixed $value = 1): int | bool |
|
| 200 | 200 | { |
| 201 | 201 | return $this->memcached->decrement($this->prefix.$key, $value = 1); |
| 202 | 202 | } |
@@ -297,11 +297,11 @@ |
||
| 297 | 297 | return $this->files; |
| 298 | 298 | } |
| 299 | 299 | |
| 300 | - /** |
|
| 301 | - * Gets the cache key prefix. |
|
| 302 | - * |
|
| 303 | - * @return string |
|
| 304 | - */ |
|
| 300 | + /** |
|
| 301 | + * Gets the cache key prefix. |
|
| 302 | + * |
|
| 303 | + * @return string |
|
| 304 | + */ |
|
| 305 | 305 | public function getPrefix(): string |
| 306 | 306 | { |
| 307 | 307 | return ''; |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | * |
| 206 | 206 | * @return int|bool |
| 207 | 207 | */ |
| 208 | - public function increment(string $key, mixed $value = 1): int|bool |
|
| 208 | + public function increment(string $key, mixed $value = 1): int | bool |
|
| 209 | 209 | { |
| 210 | 210 | $raw = $this->getPayLoad($key); |
| 211 | 211 | $int = ((int) $raw['data']) + $value; |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | * |
| 224 | 224 | * @return int|bool |
| 225 | 225 | */ |
| 226 | - public function decrement(string $key, mixed $value = 1): int|bool |
|
| 226 | + public function decrement(string $key, mixed $value = 1): int | bool |
|
| 227 | 227 | { |
| 228 | 228 | return $this->increment($key, $value * -1); |
| 229 | 229 | } |
@@ -163,9 +163,9 @@ discard block |
||
| 163 | 163 | * |
| 164 | 164 | * @return int|bool |
| 165 | 165 | */ |
| 166 | - public function increment(string $key, mixed $value = 1): int|bool |
|
| 166 | + public function increment(string $key, mixed $value = 1): int | bool |
|
| 167 | 167 | { |
| 168 | - return $this->incrementOrDecrement($key, $value, function ($current, $value) { |
|
| 168 | + return $this->incrementOrDecrement($key, $value, function($current, $value) { |
|
| 169 | 169 | return $current + $value; |
| 170 | 170 | }); |
| 171 | 171 | } |
@@ -178,9 +178,9 @@ discard block |
||
| 178 | 178 | * |
| 179 | 179 | * @return int|bool |
| 180 | 180 | */ |
| 181 | - public function decrement(string $key, mixed $value = 1): int|bool |
|
| 181 | + public function decrement(string $key, mixed $value = 1): int | bool |
|
| 182 | 182 | { |
| 183 | - return $this->incrementOrDecrement($key, $value, function ($current, $value) { |
|
| 183 | + return $this->incrementOrDecrement($key, $value, function($current, $value) { |
|
| 184 | 184 | return $current - $value; |
| 185 | 185 | }); |
| 186 | 186 | } |
@@ -194,9 +194,9 @@ discard block |
||
| 194 | 194 | * |
| 195 | 195 | * @return int|bool |
| 196 | 196 | */ |
| 197 | - protected function incrementOrDecrement(string $key, mixed $value, Closure $callback): int|bool |
|
| 197 | + protected function incrementOrDecrement(string $key, mixed $value, Closure $callback): int | bool |
|
| 198 | 198 | { |
| 199 | - return $this->connection->transaction(function () use ($key, $value, $callback) { |
|
| 199 | + return $this->connection->transaction(function() use ($key, $value, $callback) { |
|
| 200 | 200 | $prefixed = $this->prefix.$key; |
| 201 | 201 | $cache = $this->table()->where('key', $prefixed)->first(); |
| 202 | 202 | |
@@ -90,7 +90,9 @@ discard block |
||
| 90 | 90 | |
| 91 | 91 | $cache = $this->table()->where('key', '=', $prefixed)->first(); |
| 92 | 92 | |
| 93 | - if (is_null($cache)) return; |
|
| 93 | + if (is_null($cache)) { |
|
| 94 | + return; |
|
| 95 | + } |
|
| 94 | 96 | |
| 95 | 97 | $cache = is_array($cache) ? (object) $cache : $cache; |
| 96 | 98 | |
@@ -200,7 +202,9 @@ discard block |
||
| 200 | 202 | $prefixed = $this->prefix.$key; |
| 201 | 203 | $cache = $this->table()->where('key', $prefixed)->first(); |
| 202 | 204 | |
| 203 | - if (is_null($cache)) return false; |
|
| 205 | + if (is_null($cache)) { |
|
| 206 | + return false; |
|
| 207 | + } |
|
| 204 | 208 | |
| 205 | 209 | $cache = is_array($cache) ? (object) $cache : $cache; |
| 206 | 210 | |
@@ -208,7 +212,9 @@ discard block |
||
| 208 | 212 | |
| 209 | 213 | $result = $callback((int) $current, $value); |
| 210 | 214 | |
| 211 | - if ( ! is_numeric($current)) return false; |
|
| 215 | + if ( ! is_numeric($current)) { |
|
| 216 | + return false; |
|
| 217 | + } |
|
| 212 | 218 | |
| 213 | 219 | $this->table()->where('key', $prefixed)->update([ |
| 214 | 220 | 'value' => $this->serialize($result), |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | * |
| 79 | 79 | * @return int|bool |
| 80 | 80 | */ |
| 81 | - public function increment(string $key, mixed $value): int|bool |
|
| 81 | + public function increment(string $key, mixed $value): int | bool |
|
| 82 | 82 | { |
| 83 | 83 | return $this->apcu ? apcu_inc($key, $value) : apc_inc($key, $value); |
| 84 | 84 | } |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | * |
| 92 | 92 | * @return int|bool |
| 93 | 93 | */ |
| 94 | - public function decrement(string $key, mixed $value): int|bool |
|
| 94 | + public function decrement(string $key, mixed $value): int | bool |
|
| 95 | 95 | { |
| 96 | 96 | return $this->apcu ? apcu_dec($key, $value) : apc_dec($key, $value); |
| 97 | 97 | } |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | * |
| 99 | 99 | * @return int|bool |
| 100 | 100 | */ |
| 101 | - public function increment(string $key, mixed $value = 1): int|bool |
|
| 101 | + public function increment(string $key, mixed $value = 1): int | bool |
|
| 102 | 102 | { |
| 103 | 103 | return $this->apc->increment($this->prefix.$key, $value); |
| 104 | 104 | } |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | * |
| 112 | 112 | * @return int|bool |
| 113 | 113 | */ |
| 114 | - public function decrement(string $key, mixed $value = 1): int|bool |
|
| 114 | + public function decrement(string $key, mixed $value = 1): int | bool |
|
| 115 | 115 | { |
| 116 | 116 | return $this->apc->decrement($this->prefix.$key, $value); |
| 117 | 117 | } |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | * |
| 74 | 74 | * @return int|bool |
| 75 | 75 | */ |
| 76 | - public function increment(string $key, mixed $value = 1): int|bool |
|
| 76 | + public function increment(string $key, mixed $value = 1): int | bool |
|
| 77 | 77 | { |
| 78 | 78 | return false; |
| 79 | 79 | } |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | * |
| 87 | 87 | * @return int|bool |
| 88 | 88 | */ |
| 89 | - public function decrement(string $key, mixed $value = 1): int|bool |
|
| 89 | + public function decrement(string $key, mixed $value = 1): int | bool |
|
| 90 | 90 | { |
| 91 | 91 | return false; |
| 92 | 92 | } |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | { |
| 94 | 94 | $results = []; |
| 95 | 95 | |
| 96 | - $values = $this->connection()->mget(array_map(function ($key) { |
|
| 96 | + $values = $this->connection()->mget(array_map(function($key) { |
|
| 97 | 97 | return $this->prefix.$key; |
| 98 | 98 | }, $keys)); |
| 99 | 99 | |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | * |
| 156 | 156 | * @return int|bool |
| 157 | 157 | */ |
| 158 | - public function increment(string $key, mixed $value = 1): int|bool |
|
| 158 | + public function increment(string $key, mixed $value = 1): int | bool |
|
| 159 | 159 | { |
| 160 | 160 | return $this->connection()->incrby($this->prefix.$key, $value); |
| 161 | 161 | } |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | * |
| 169 | 169 | * @return int|bool |
| 170 | 170 | */ |
| 171 | - public function decrement(string $key, mixed $value = 1): int|bool |
|
| 171 | + public function decrement(string $key, mixed $value = 1): int | bool |
|
| 172 | 172 | { |
| 173 | 173 | return $this->connection()->decrby($this->prefix.$key, $value); |
| 174 | 174 | } |
@@ -149,8 +149,8 @@ discard block |
||
| 149 | 149 | */ |
| 150 | 150 | protected function call(): Closure |
| 151 | 151 | { |
| 152 | - return function ($stack, $pipe) { |
|
| 153 | - return function ($passable) use ($stack, $pipe) { |
|
| 152 | + return function($stack, $pipe) { |
|
| 153 | + return function($passable) use ($stack, $pipe) { |
|
| 154 | 154 | try { |
| 155 | 155 | if (is_callable($pipe)) { |
| 156 | 156 | return $pipe($passable, $stack); |
@@ -203,10 +203,10 @@ discard block |
||
| 203 | 203 | */ |
| 204 | 204 | protected function prepareDestination(Closure $destination): Closure |
| 205 | 205 | { |
| 206 | - return function ($passable) use ($destination) { |
|
| 206 | + return function($passable) use ($destination) { |
|
| 207 | 207 | try { |
| 208 | 208 | return $destination($passable); |
| 209 | - } catch(Throwable $e) { |
|
| 209 | + } catch (Throwable $e) { |
|
| 210 | 210 | return $this->handleException($passable, $e); |
| 211 | 211 | } |
| 212 | 212 | }; |