@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | throw new InvalidArgumentException('Empty key not allowed'); |
| 122 | 122 | } |
| 123 | 123 | try { |
| 124 | - $sth = $this->handle->prepare('SELECT `key` FROM ' . $this->tablename . ' WHERE `key` = ?'); |
|
| 124 | + $sth = $this->handle->prepare('SELECT `key` FROM '.$this->tablename.' WHERE `key` = ?'); |
|
| 125 | 125 | $sth->execute(array($key)); |
| 126 | 126 | return $sth->fetchColumn() !== false; |
| 127 | 127 | } |
@@ -141,9 +141,9 @@ discard block |
||
| 141 | 141 | */ |
| 142 | 142 | private function cleanExpired(): void { |
| 143 | 143 | try { |
| 144 | - $sth = $this->handle->prepare("DELETE FROM " . $this->tablename . " WHERE `expire` < ? AND NOT `expire` = 0"); |
|
| 144 | + $sth = $this->handle->prepare("DELETE FROM ".$this->tablename." WHERE `expire` < ? AND NOT `expire` = 0"); |
|
| 145 | 145 | $sth->execute(array(time())); |
| 146 | - $deletedRows=$sth->rowCount(); |
|
| 146 | + $deletedRows = $sth->rowCount(); |
|
| 147 | 147 | $this->logger->notice( |
| 148 | 148 | sprintf("Deleted %d expired keys", $deletedRows) |
| 149 | 149 | ); |
@@ -159,12 +159,12 @@ discard block |
||
| 159 | 159 | /** |
| 160 | 160 | * @see Tiqr_StateStorage_StateStorageInterface::setValue() |
| 161 | 161 | */ |
| 162 | - public function setValue(string $key, $value, int $expire=0): void |
|
| 162 | + public function setValue(string $key, $value, int $expire = 0): void |
|
| 163 | 163 | { |
| 164 | 164 | if (empty($key)) { |
| 165 | 165 | throw new InvalidArgumentException('Empty key not allowed'); |
| 166 | 166 | } |
| 167 | - if (((float) rand() /(float) getrandmax()) < $this->cleanupProbability) { |
|
| 167 | + if (((float) rand() / (float) getrandmax()) < $this->cleanupProbability) { |
|
| 168 | 168 | $this->cleanExpired(); |
| 169 | 169 | } |
| 170 | 170 | // REPLACE INTO is mysql dialect. Supported by sqlite as well. |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | |
| 178 | 178 | // $expire == 0 means never expire |
| 179 | 179 | if ($expire != 0) { |
| 180 | - $expire+=time(); // Store unix timestamp after which the key expires |
|
| 180 | + $expire += time(); // Store unix timestamp after which the key expires |
|
| 181 | 181 | } |
| 182 | 182 | try { |
| 183 | 183 | $sth->execute(array(serialize($value), $expire, $key)); |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | throw new InvalidArgumentException('Empty key not allowed'); |
| 201 | 201 | } |
| 202 | 202 | try { |
| 203 | - $sth = $this->handle->prepare("DELETE FROM " . $this->tablename . " WHERE `key` = ?"); |
|
| 203 | + $sth = $this->handle->prepare("DELETE FROM ".$this->tablename." WHERE `key` = ?"); |
|
| 204 | 204 | $sth->execute(array($key)); |
| 205 | 205 | } |
| 206 | 206 | catch (Exception $e) { |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | try { |
| 233 | - $sth = $this->handle->prepare('SELECT `value` FROM ' . $this->tablename . ' WHERE `key` = ? AND (`expire` >= ? OR `expire` = 0)'); |
|
| 233 | + $sth = $this->handle->prepare('SELECT `value` FROM '.$this->tablename.' WHERE `key` = ? AND (`expire` >= ? OR `expire` = 0)'); |
|
| 234 | 234 | $sth->execute(array($key, time())); |
| 235 | 235 | } |
| 236 | 236 | catch (Exception $e) { |
@@ -244,9 +244,9 @@ discard block |
||
| 244 | 244 | if (false === $result) { |
| 245 | 245 | // Occurs normally |
| 246 | 246 | $this->logger->info(sprintf('getValue: Key "%s" not found in PDO StateStorage', $key)); |
| 247 | - return NULL; // Key not found |
|
| 247 | + return NULL; // Key not found |
|
| 248 | 248 | } |
| 249 | - $result=unserialize($result, array('allowed_classes' => false)); |
|
| 249 | + $result = unserialize($result, array('allowed_classes' => false)); |
|
| 250 | 250 | if (false === $result) { |
| 251 | 251 | throw new RuntimeException(sprintf('getValue: unserialize error for key "%s" in PDO StateStorage', $key)); |
| 252 | 252 | } |