@@ -117,9 +117,9 @@ discard block |
||
| 117 | 117 | */ |
| 118 | 118 | private function cleanExpired(): void { |
| 119 | 119 | try { |
| 120 | - $sth = $this->handle->prepare("DELETE FROM " . $this->tablename . " WHERE `expire` < ? AND NOT `expire` = 0"); |
|
| 120 | + $sth = $this->handle->prepare("DELETE FROM ".$this->tablename." WHERE `expire` < ? AND NOT `expire` = 0"); |
|
| 121 | 121 | $sth->execute(array(time())); |
| 122 | - $deletedRows=$sth->rowCount(); |
|
| 122 | + $deletedRows = $sth->rowCount(); |
|
| 123 | 123 | $this->logger->notice( |
| 124 | 124 | sprintf("Deleted %d expired keys", $deletedRows) |
| 125 | 125 | ); |
@@ -135,12 +135,12 @@ discard block |
||
| 135 | 135 | /** |
| 136 | 136 | * @see Tiqr_StateStorage_StateStorageInterface::setValue() |
| 137 | 137 | */ |
| 138 | - public function setValue(string $key, $value, int $expire=0): void |
|
| 138 | + public function setValue(string $key, $value, int $expire = 0): void |
|
| 139 | 139 | { |
| 140 | 140 | if (empty($key)) { |
| 141 | 141 | throw new InvalidArgumentException('Empty key not allowed'); |
| 142 | 142 | } |
| 143 | - if (((float) rand() /(float) getrandmax()) < $this->cleanupProbability) { |
|
| 143 | + if (((float) rand() / (float) getrandmax()) < $this->cleanupProbability) { |
|
| 144 | 144 | $this->cleanExpired(); |
| 145 | 145 | } |
| 146 | 146 | // REPLACE INTO is mysql dialect. Supported by sqlite as well. |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | |
| 154 | 154 | // $expire == 0 means never expire |
| 155 | 155 | if ($expire != 0) { |
| 156 | - $expire+=time(); // Store unix timestamp after which the key expires |
|
| 156 | + $expire += time(); // Store unix timestamp after which the key expires |
|
| 157 | 157 | } |
| 158 | 158 | try { |
| 159 | 159 | $sth->execute(array(serialize($value), $expire, $key)); |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | throw new InvalidArgumentException('Empty key not allowed'); |
| 177 | 177 | } |
| 178 | 178 | try { |
| 179 | - $sth = $this->handle->prepare("DELETE FROM " . $this->tablename . " WHERE `key` = ?"); |
|
| 179 | + $sth = $this->handle->prepare("DELETE FROM ".$this->tablename." WHERE `key` = ?"); |
|
| 180 | 180 | $sth->execute(array($key)); |
| 181 | 181 | } |
| 182 | 182 | catch (Exception $e) { |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | try { |
| 209 | - $sth = $this->handle->prepare('SELECT `value` FROM ' . $this->tablename . ' WHERE `key` = ? AND (`expire` >= ? OR `expire` = 0)'); |
|
| 209 | + $sth = $this->handle->prepare('SELECT `value` FROM '.$this->tablename.' WHERE `key` = ? AND (`expire` >= ? OR `expire` = 0)'); |
|
| 210 | 210 | $sth->execute(array($key, time())); |
| 211 | 211 | } |
| 212 | 212 | catch (Exception $e) { |
@@ -220,9 +220,9 @@ discard block |
||
| 220 | 220 | if (false === $result) { |
| 221 | 221 | // Occurs normally |
| 222 | 222 | $this->logger->info(sprintf('getValue: Key "%s" not found in PDO StateStorage', $key)); |
| 223 | - return NULL; // Key not found |
|
| 223 | + return NULL; // Key not found |
|
| 224 | 224 | } |
| 225 | - $result=unserialize($result, array('allowed_classes' => false)); |
|
| 225 | + $result = unserialize($result, array('allowed_classes' => false)); |
|
| 226 | 226 | if (false === $result) { |
| 227 | 227 | throw new RuntimeException(sprintf('getValue: unserialize error for key "%s" in PDO StateStorage', $key)); |
| 228 | 228 | } |