Passed
Push — master ( 2dccb2...0c7471 )
by Pieter van der
04:22 queued 01:07
created
library/tiqr/Tiqr/StateStorage/Pdo.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
         if ($this->keyExists($key)) {
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
         }
175 175
         // $expire == 0 means never expire
176 176
         if ($expire != 0) {
177
-            $expire+=time();    // Store unix timestamp after which the key expires
177
+            $expire += time(); // Store unix timestamp after which the key expires
178 178
         }
179 179
         try {
180 180
             $sth->execute(array(serialize($value), $expire, $key));
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
             throw new InvalidArgumentException('Empty key not allowed');
198 198
         }
199 199
         try {
200
-            $sth = $this->handle->prepare("DELETE FROM " . $this->tablename . " WHERE `key` = ?");
200
+            $sth = $this->handle->prepare("DELETE FROM ".$this->tablename." WHERE `key` = ?");
201 201
             $sth->execute(array($key));
202 202
         }
203 203
         catch (Exception $e) {
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
         }
228 228
 
229 229
         try {
230
-            $sth = $this->handle->prepare('SELECT `value` FROM ' . $this->tablename . ' WHERE `key` = ? AND (`expire` >= ? OR `expire` = 0)');
230
+            $sth = $this->handle->prepare('SELECT `value` FROM '.$this->tablename.' WHERE `key` = ? AND (`expire` >= ? OR `expire` = 0)');
231 231
             $sth->execute(array($key, time()));
232 232
         }
233 233
         catch (Exception $e) {
@@ -241,9 +241,9 @@  discard block
 block discarded – undo
241 241
         if (false === $result) {
242 242
             // Occurs normally
243 243
             $this->logger->info(sprintf('getValue: Key "%s" not found in PDO StateStorage', $key));
244
-            return NULL;    // Key not found
244
+            return NULL; // Key not found
245 245
         }
246
-        $result=unserialize($result, array('allowed_classes' => false));
246
+        $result = unserialize($result, array('allowed_classes' => false));
247 247
         if (false === $result) {
248 248
             throw new RuntimeException(sprintf('getValue: unserialize error for key "%s" in PDO StateStorage', $key));
249 249
         }
Please login to merge, or discard this patch.