@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | { |
| 33 | 33 | $foundApc = \extension_loaded('apc'); |
| 34 | 34 | |
| 35 | - if (!$foundApc){ |
|
| 35 | + if (!$foundApc) { |
|
| 36 | 36 | throw new CacheException('APC Extension not found.'); |
| 37 | 37 | } |
| 38 | 38 | |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | * |
| 52 | 52 | * @return bool |
| 53 | 53 | */ |
| 54 | - public function has($key){ |
|
| 54 | + public function has($key) { |
|
| 55 | 55 | return \apc_exists($key); |
| 56 | 56 | } |
| 57 | 57 | |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | */ |
| 95 | 95 | public function delete($key) |
| 96 | 96 | { |
| 97 | - if (\apc_exists($key)){ |
|
| 97 | + if (\apc_exists($key)) { |
|
| 98 | 98 | \apc_delete($key); |
| 99 | 99 | } |
| 100 | 100 | } |
@@ -104,12 +104,12 @@ discard block |
||
| 104 | 104 | * |
| 105 | 105 | * @return bool True on success and false on failure. |
| 106 | 106 | */ |
| 107 | - public function clear(){ |
|
| 107 | + public function clear() { |
|
| 108 | 108 | |
| 109 | 109 | \apc_clear_cache(); |
| 110 | 110 | $apcResult = $this->getInfo(); |
| 111 | 111 | |
| 112 | - if (!empty($apcResult['cache_list'])){ |
|
| 112 | + if (!empty($apcResult['cache_list'])) { |
|
| 113 | 113 | return false; |
| 114 | 114 | } |
| 115 | 115 | |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | * |
| 123 | 123 | * @return array |
| 124 | 124 | */ |
| 125 | - public function getInfo(){ |
|
| 125 | + public function getInfo() { |
|
| 126 | 126 | return apc_cache_info(); |
| 127 | 127 | } |
| 128 | 128 | |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * @param DateInterval $ttl |
| 42 | 42 | * @return CacheStorageInterface |
| 43 | 43 | */ |
| 44 | - public function withTtl(DateInterval $ttl){ |
|
| 44 | + public function withTtl(DateInterval $ttl) { |
|
| 45 | 45 | $new = clone $this; |
| 46 | 46 | $new->ttl = $ttl; |
| 47 | 47 | return $new; |
@@ -53,11 +53,11 @@ discard block |
||
| 53 | 53 | * @param null|int $ttl |
| 54 | 54 | * @return int |
| 55 | 55 | */ |
| 56 | - public function getTtlTimestamp($ttl = null){ |
|
| 56 | + public function getTtlTimestamp($ttl = null) { |
|
| 57 | 57 | |
| 58 | - if (null === $ttl){ |
|
| 58 | + if (null === $ttl) { |
|
| 59 | 59 | $dateTime = new DateTime(); |
| 60 | - $dateTime->add( $this->ttl ); |
|
| 60 | + $dateTime->add($this->ttl); |
|
| 61 | 61 | $ttl = $dateTime->getTimestamp(); |
| 62 | 62 | } |
| 63 | 63 | |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | * |
| 70 | 70 | * @return DateInterval |
| 71 | 71 | */ |
| 72 | - public function getTtl(){ |
|
| 72 | + public function getTtl() { |
|
| 73 | 73 | return $this->ttl; |
| 74 | 74 | } |
| 75 | 75 | |
@@ -38,13 +38,13 @@ discard block |
||
| 38 | 38 | public function set($key, $value, $ttl = null) |
| 39 | 39 | { |
| 40 | 40 | //convert to timestamp from now. |
| 41 | - if ($ttl instanceof \DateInterval){ |
|
| 41 | + if ($ttl instanceof \DateInterval) { |
|
| 42 | 42 | $dateTime = new \DateTime(); |
| 43 | - $dateTime->add( $ttl ); |
|
| 43 | + $dateTime->add($ttl); |
|
| 44 | 44 | $ttl = $dateTime->getTimestamp() - time(); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - if (!is_int($ttl) || $ttl === null){ |
|
| 47 | + if (!is_int($ttl) || $ttl === null) { |
|
| 48 | 48 | throw new InvalidArgumentException('$ttl can only be an instance of \DateInterval, int or null'); |
| 49 | 49 | } |
| 50 | 50 | |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | { |
| 88 | 88 | $this->_isValidKey($key); |
| 89 | 89 | |
| 90 | - if ($this->cache->has($key)){ |
|
| 90 | + if ($this->cache->has($key)) { |
|
| 91 | 91 | return $this->cache->get($key); |
| 92 | 92 | } |
| 93 | 93 | |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | $this->_checkTraversable($keys); |
| 129 | 129 | $result = []; |
| 130 | 130 | |
| 131 | - foreach ((array)$keys as $key){ |
|
| 131 | + foreach ((array)$keys as $key) { |
|
| 132 | 132 | $cachedItem = $this->cache->get($key); |
| 133 | 133 | $result[$key] = (null !== $cachedItem) ? $cachedItem : $default; |
| 134 | 134 | } |
@@ -155,11 +155,11 @@ discard block |
||
| 155 | 155 | $this->_checkTraversable($values); |
| 156 | 156 | $results = []; |
| 157 | 157 | |
| 158 | - foreach ((array)$values as $key => $value){ |
|
| 158 | + foreach ((array)$values as $key => $value) { |
|
| 159 | 159 | $results[] = $this->cache->set($key, $value, $ttl); |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - if ($this->_hasFailure($results)){ |
|
| 162 | + if ($this->_hasFailure($results)) { |
|
| 163 | 163 | return false; |
| 164 | 164 | } |
| 165 | 165 | |
@@ -182,11 +182,11 @@ discard block |
||
| 182 | 182 | $this->_checkTraversable($keys); |
| 183 | 183 | $results = []; |
| 184 | 184 | |
| 185 | - foreach ((array)$keys as $key){ |
|
| 185 | + foreach ((array)$keys as $key) { |
|
| 186 | 186 | $results[] = $this->cache->delete($key); |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | - if ($this->_hasFailure($results)){ |
|
| 189 | + if ($this->_hasFailure($results)) { |
|
| 190 | 190 | return false; |
| 191 | 191 | } |
| 192 | 192 | |
@@ -209,15 +209,15 @@ discard block |
||
| 209 | 209 | * @param $key |
| 210 | 210 | * @throws InvalidArgumentException |
| 211 | 211 | */ |
| 212 | - private function _isValidKey($key){ |
|
| 213 | - if (!is_string($key)){ |
|
| 212 | + private function _isValidKey($key) { |
|
| 213 | + if (!is_string($key)) { |
|
| 214 | 214 | throw new InvalidArgumentException('provided key must be a valid string'); |
| 215 | 215 | } |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | private function isAssoc(array $arr) |
| 219 | 219 | { |
| 220 | - if (array() === $arr){ |
|
| 220 | + if (array() === $arr) { |
|
| 221 | 221 | return false; |
| 222 | 222 | } |
| 223 | 223 | return array_keys($arr) !== range(0, count($arr) - 1); |
@@ -230,13 +230,13 @@ discard block |
||
| 230 | 230 | * @throws InvalidArgumentException |
| 231 | 231 | * @internal |
| 232 | 232 | */ |
| 233 | - private function _checkTraversable($data){ |
|
| 233 | + private function _checkTraversable($data) { |
|
| 234 | 234 | |
| 235 | - if (is_array($data)){ |
|
| 235 | + if (is_array($data)) { |
|
| 236 | 236 | return; |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | - if ($data instanceof \Traversable ){ |
|
| 239 | + if ($data instanceof \Traversable) { |
|
| 240 | 240 | return; |
| 241 | 241 | } |
| 242 | 242 | |
@@ -250,8 +250,8 @@ discard block |
||
| 250 | 250 | * @return bool |
| 251 | 251 | * @internal |
| 252 | 252 | */ |
| 253 | - private function _hasFailure(array $results){ |
|
| 254 | - if (in_array(false, $results)){ |
|
| 253 | + private function _hasFailure(array $results) { |
|
| 254 | + if (in_array(false, $results)) { |
|
| 255 | 255 | return true; |
| 256 | 256 | } |
| 257 | 257 | return false; |