Passed
Pull Request — develop (#45)
by Pieter van der
03:19
created
library/tiqr/Tiqr/UserSecretStorage/File.php 1 patch
Indentation   -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,6 @@
 block discarded – undo
35 35
  * Supported options:
36 36
  * path : Path to the directory where the user data is stored
37 37
  *
38
-
39 38
  */
40 39
 class Tiqr_UserSecretStorage_File implements Tiqr_UserSecretStorage_Interface
41 40
 {
Please login to merge, or discard this patch.
library/tiqr/Tiqr/UserSecretStorage/Pdo.php 1 patch
Indentation   -1 removed lines patch added patch discarded remove patch
@@ -42,7 +42,6 @@
 block discarded – undo
42 42
     userid varchar(30) NOT NULL UNIQUE,
43 43
     secret varchar(128),
44 44
 );
45
-
46 45
  * @see Tiqr_UserSecretStorage::getSecretStorage()
47 46
  * @see Tiqr_UserSecretStorage_Interface
48 47
  *
Please login to merge, or discard this patch.
library/tiqr/Tiqr/StateStorage/Pdo.php 2 patches
Indentation   -1 removed lines patch added patch discarded remove patch
@@ -59,7 +59,6 @@
 block discarded – undo
59 59
 );
60 60
 
61 61
 CREATE INDEX IF NOT EXISTS index_tiqrstate_expire ON tiqrstate (expire);
62
-
63 62
  * @see Tiqr_StateStorage::getStorage()
64 63
  * @see Tiqr_StateStorage_StateStorageInterface
65 64
  *
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
             throw new InvalidArgumentException('Empty key not allowed');
124 124
         }
125 125
         try {
126
-            $sth = $this->handle->prepare('SELECT `key` FROM ' . $this->tablename . ' WHERE `key` = ?');
126
+            $sth = $this->handle->prepare('SELECT `key` FROM '.$this->tablename.' WHERE `key` = ?');
127 127
             $sth->execute(array($key));
128 128
             return $sth->fetchColumn() !== false;
129 129
         }
@@ -143,9 +143,9 @@  discard block
 block discarded – undo
143 143
      */
144 144
     private function cleanExpired(): void {
145 145
         try {
146
-            $sth = $this->handle->prepare("DELETE FROM " . $this->tablename . " WHERE `expire` < ? AND NOT `expire` = 0");
146
+            $sth = $this->handle->prepare("DELETE FROM ".$this->tablename." WHERE `expire` < ? AND NOT `expire` = 0");
147 147
             $sth->execute(array(time()));
148
-            $deletedRows=$sth->rowCount();
148
+            $deletedRows = $sth->rowCount();
149 149
             $this->logger->notice(
150 150
                 sprintf("Deleted %i expired keys", $deletedRows)
151 151
             );
@@ -161,12 +161,12 @@  discard block
 block discarded – undo
161 161
     /**
162 162
      * @see Tiqr_StateStorage_StateStorageInterface::setValue()
163 163
      */
164
-    public function setValue(string $key, $value, int $expire=0): void
164
+    public function setValue(string $key, $value, int $expire = 0): void
165 165
     {
166 166
         if (empty($key)) {
167 167
             throw new InvalidArgumentException('Empty key not allowed');
168 168
         }
169
-        if (((float) rand() /(float) getrandmax()) < $this->cleanupProbability) {
169
+        if (((float) rand() / (float) getrandmax()) < $this->cleanupProbability) {
170 170
             $this->cleanExpired();
171 171
         }
172 172
         if ($this->keyExists($key)) {
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
         }
177 177
         // $expire == 0 means never expire
178 178
         if ($expire != 0) {
179
-            $expire+=time();    // Store unix timestamp after which the key expires
179
+            $expire += time(); // Store unix timestamp after which the key expires
180 180
         }
181 181
         try {
182 182
             $sth->execute(array(serialize($value), $expire, $key));
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
             throw new InvalidArgumentException('Empty key not allowed');
200 200
         }
201 201
         try {
202
-            $sth = $this->handle->prepare("DELETE FROM " . $this->tablename . " WHERE `key` = ?");
202
+            $sth = $this->handle->prepare("DELETE FROM ".$this->tablename." WHERE `key` = ?");
203 203
             $sth->execute(array($key));
204 204
         }
205 205
         catch (Exception $e) {
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
         }
230 230
 
231 231
         try {
232
-            $sth = $this->handle->prepare('SELECT `value` FROM ' . $this->tablename . ' WHERE `key` = ? AND (`expire` >= ? OR `expire` = 0)');
232
+            $sth = $this->handle->prepare('SELECT `value` FROM '.$this->tablename.' WHERE `key` = ? AND (`expire` >= ? OR `expire` = 0)');
233 233
             $sth->execute(array($key, time()));
234 234
         }
235 235
         catch (Exception $e) {
@@ -243,9 +243,9 @@  discard block
 block discarded – undo
243 243
         if (false === $result) {
244 244
             // Occurs normally
245 245
             $this->logger->info(sprintf('getValue: Key "%s" not found in PDO StateStorage', $key));
246
-            return NULL;    // Key not found
246
+            return NULL; // Key not found
247 247
         }
248
-        $result=unserialize($result, array('allowed_classes' => false));
248
+        $result = unserialize($result, array('allowed_classes' => false));
249 249
         if (false === $result) {
250 250
             throw new RuntimeException(sprintf('getValue: unserialize error for key "%s" in PDO StateStorage', $key));
251 251
         }
Please login to merge, or discard this patch.