Passed
Push — develop ( afb057...0a569b )
by Pieter van der
01:05 queued 14s
created
library/tiqr/Tiqr/OcraService/Tiqr.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -36,8 +36,7 @@
 block discarded – undo
36 36
         // response as the client calculated.
37 37
         try {
38 38
             $expected = OCRA::generateOCRA($this->_ocraSuite, $userSecret, "", $challenge, "", $sessionInformation, "");
39
-        }
40
-        catch (Exception $e) {
39
+        } catch (Exception $e) {
41 40
             $this->logger->warning(sprintf('Error calculating OCRA response for user "%s"', $userId), array('exception'=>$e));
42 41
             return false;
43 42
         }
Please login to merge, or discard this patch.
library/tiqr/Tiqr/Message/APNS2.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -28,8 +28,7 @@
 block discarded – undo
28 28
             // Use HTTP/1.1 instead of HTTP/2
29 29
             $curl_options[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_1;
30 30
             $this->logger->notice(sprintf('Using HTTP/1.1 CURL Proxy URL: "%s" and port "%s"',  $curl_options[CURLOPT_URL], $curl_options[CURLOPT_URL]));
31
-        }
32
-        else {
31
+        } else {
33 32
             $version_info = curl_version();
34 33
             if ($version_info['features'] & CURL_VERSION_HTTP2 == 0) {
35 34
                 throw new RuntimeException('APNS2 requires HTTP/2 support in curl');
Please login to merge, or discard this patch.
library/tiqr/Tiqr/OcraService.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -41,8 +41,9 @@
 block discarded – undo
41 41
      */
42 42
     public static function getOcraService(string $type="tiqr", array $options=array(), LoggerInterface $logger=null)
43 43
     {
44
-        if (!$logger)
45
-            $logger=new \Psr\Log\NullLogger();
44
+        if (!$logger) {
45
+                    $logger=new \Psr\Log\NullLogger();
46
+        }
46 47
 
47 48
         switch ($type) {
48 49
             case "tiqr":
Please login to merge, or discard this patch.
library/tiqr/Tiqr/Service.php 1 patch
Braces   +8 added lines, -7 removed lines patch added patch discarded remove patch
@@ -287,8 +287,7 @@  discard block
 block discarded – undo
287 287
         if (isset($options['ocraservice']) && $options['ocraservice']['type'] != 'tiqr') {
288 288
             $options['ocraservice']['ocra.suite'] = $this->_ocraSuite;
289 289
             $this->_ocraService = Tiqr_OcraService::getOcraService($options['ocraservice']['type'], $options['ocraservice'], $logger);
290
-        }
291
-        else { // Create default ocraservice
290
+        } else { // Create default ocraservice
292 291
             $this->_ocraService = Tiqr_OcraService::getOcraService('tiqr', array('ocra.suite' => $this->_ocraSuite), $logger);
293 292
         }
294 293
     }
@@ -347,8 +346,9 @@  discard block
 block discarded – undo
347 346
                 case 'APNS':
348 347
                 case 'APNS_DIRECT':
349 348
                     $apns_version = $this->_options['apns.version'] ?? 2;
350
-                    if ($apns_version !=2)
351
-                        throw new InvalidArgumentException("Unsupported APNS version '$apns_version'");
349
+                    if ($apns_version !=2) {
350
+                                            throw new InvalidArgumentException("Unsupported APNS version '$apns_version'");
351
+                    }
352 352
                     $message = new Tiqr_Message_APNS2($this->_options, $this->logger);
353 353
                     break;
354 354
 
@@ -514,7 +514,9 @@  discard block
 block discarded – undo
514 514
             $sessionId = session_id(); 
515 515
         }
516 516
         $status = $this->_getStateValue(self::PREFIX_ENROLLMENT_STATUS, $sessionId);
517
-        if (is_null($status)) return self::ENROLLMENT_STATUS_IDLE;
517
+        if (is_null($status)) {
518
+            return self::ENROLLMENT_STATUS_IDLE;
519
+        }
518 520
         return $status;
519 521
     }
520 522
         
@@ -871,8 +873,7 @@  discard block
 block discarded – undo
871 873
         
872 874
         try {
873 875
             return $this->_getStateValue("authenticated_", $sessionId);
874
-        }
875
-        catch (Exception $e) {
876
+        } catch (Exception $e) {
876 877
             $this->logger->error('getAuthenticatedUser failed', array('exception'=>$e));
877 878
             return NULL;
878 879
         }
Please login to merge, or discard this patch.
library/tiqr/Tiqr/DeviceStorage.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -42,8 +42,9 @@
 block discarded – undo
42 42
      */
43 43
     public static function getStorage(string $type="dummy", Array $options=array(), LoggerInterface $logger=null)
44 44
     {
45
-        if (!$logger)
46
-            $logger=new \Psr\Log\NullLogger();
45
+        if (!$logger) {
46
+                    $logger=new \Psr\Log\NullLogger();
47
+        }
47 48
 
48 49
         switch ($type) {
49 50
             case "dummy":
Please login to merge, or discard this patch.
library/tiqr/Tiqr/OATH/OCRA.php 1 patch
Braces   +45 added lines, -33 removed lines patch added patch discarded remove patch
@@ -125,13 +125,13 @@  discard block
 block discarded – undo
125 125
         $cryptoFunction = $components[1];
126 126
         $dataInput = strtolower($components[2]); // lower here so we can do case insensitive comparisons
127 127
 
128
-        if(stripos($cryptoFunction, "hotp-sha1")!==false)
129
-            $crypto = "sha1";
130
-        elseif(stripos($cryptoFunction, "hotp-sha256")!==false)
131
-            $crypto = "sha256";
132
-        elseif(stripos($cryptoFunction, "hotp-sha512")!==false)
133
-            $crypto = "sha512";
134
-        else {
128
+        if(stripos($cryptoFunction, "hotp-sha1")!==false) {
129
+                    $crypto = "sha1";
130
+        } elseif(stripos($cryptoFunction, "hotp-sha256")!==false) {
131
+                    $crypto = "sha256";
132
+        } elseif(stripos($cryptoFunction, "hotp-sha512")!==false) {
133
+                    $crypto = "sha512";
134
+        } else {
135 135
             throw new InvalidArgumentException('Unsupported OCRA CryptoFunction');
136 136
         }
137 137
 
@@ -149,56 +149,65 @@  discard block
 block discarded – undo
149 149
         // Counter
150 150
         if($dataInput[0] == "c" ) {
151 151
             // Fix the length of the HEX string
152
-            while(strlen($counter) < 16)
153
-                $counter = "0" . $counter;
152
+            while(strlen($counter) < 16) {
153
+                            $counter = "0" . $counter;
154
+            }
154 155
             $counterLength=8;
155 156
         }
156 157
         // Question
157 158
         if($dataInput[0] == "q" ||
158 159
                 stripos($dataInput, "-q")!==false) {
159
-            while(strlen($question) < 256)
160
-                $question = $question . "0";
160
+            while(strlen($question) < 256) {
161
+                            $question = $question . "0";
162
+            }
161 163
             $questionLength=128;
162 164
         }
163 165
 
164 166
         // Password
165 167
         if(stripos($dataInput, "psha1")!==false) {
166
-            while(strlen($password) < 40)
167
-                $password = "0" . $password;
168
+            while(strlen($password) < 40) {
169
+                            $password = "0" . $password;
170
+            }
168 171
             $passwordLength=20;
169 172
         }
170 173
     
171 174
         if(stripos($dataInput, "psha256")!==false) {
172
-            while(strlen($password) < 64)
173
-                $password = "0" . $password;
175
+            while(strlen($password) < 64) {
176
+                            $password = "0" . $password;
177
+            }
174 178
             $passwordLength=32;
175 179
         }
176 180
         
177 181
         if(stripos($dataInput, "psha512")!==false) {
178
-            while(strlen($password) < 128)
179
-                $password = "0" . $password;
182
+            while(strlen($password) < 128) {
183
+                            $password = "0" . $password;
184
+            }
180 185
             $passwordLength=64;
181 186
         }
182 187
         
183 188
         // sessionInformation
184 189
         if(stripos($dataInput, "s064") !==false) {
185
-            while(strlen($sessionInformation) < 128)
186
-                $sessionInformation = "0" . $sessionInformation;
190
+            while(strlen($sessionInformation) < 128) {
191
+                            $sessionInformation = "0" . $sessionInformation;
192
+            }
187 193
 
188 194
             $sessionInformationLength=64;
189 195
         } else if(stripos($dataInput, "s128") !==false) {
190
-            while(strlen($sessionInformation) < 256)
191
-                $sessionInformation = "0" . $sessionInformation;
196
+            while(strlen($sessionInformation) < 256) {
197
+                            $sessionInformation = "0" . $sessionInformation;
198
+            }
192 199
         
193 200
             $sessionInformationLength=128;
194 201
         } else if(stripos($dataInput, "s256") !==false) {
195
-            while(strlen($sessionInformation) < 512)
196
-                $sessionInformation = "0" . $sessionInformation;
202
+            while(strlen($sessionInformation) < 512) {
203
+                            $sessionInformation = "0" . $sessionInformation;
204
+            }
197 205
         
198 206
             $sessionInformationLength=256;
199 207
         } else if(stripos($dataInput, "s512") !==false) {
200
-            while(strlen($sessionInformation) < 128)
201
-                $sessionInformation = "0" . $sessionInformation;
208
+            while(strlen($sessionInformation) < 128) {
209
+                            $sessionInformation = "0" . $sessionInformation;
210
+            }
202 211
         
203 212
             $sessionInformationLength=64;
204 213
         } else if (stripos($dataInput, "-s") !== false ) {
@@ -210,8 +219,9 @@  discard block
 block discarded – undo
210 219
             // to prevent matching the "s" in the password input e.g. "psha1".
211 220
             // [C] | QFxx | [PH | Snnn | TG] : Challenge-Response computation
212 221
             // [C] | QFxx | [PH | TG] : Plain Signature computation
213
-            while(strlen($sessionInformation) < 128)
214
-                $sessionInformation = "0" . $sessionInformation;
222
+            while(strlen($sessionInformation) < 128) {
223
+                            $sessionInformation = "0" . $sessionInformation;
224
+            }
215 225
             
216 226
             $sessionInformationLength=64;
217 227
         }
@@ -221,8 +231,9 @@  discard block
 block discarded – undo
221 231
         // TimeStamp
222 232
         if($dataInput[0] == "t" ||
223 233
                 stripos($dataInput, "-t") !== false) {
224
-            while(strlen($timeStamp) < 16)
225
-                $timeStamp = "0" . $timeStamp;
234
+            while(strlen($timeStamp) < 16) {
235
+                            $timeStamp = "0" . $timeStamp;
236
+            }
226 237
             $timeStampLength=8;
227 238
         }
228 239
 
@@ -289,10 +300,11 @@  discard block
 block discarded – undo
289 300
 
290 301
         $hash = self::_hmac($crypto, $byteKey, $msg);
291 302
 
292
-        if ($codeDigits == 0)
293
-            $result = $hash;
294
-        else
295
-            $result = self::_oath_truncate($hash, $codeDigits);
303
+        if ($codeDigits == 0) {
304
+                    $result = $hash;
305
+        } else {
306
+                    $result = self::_oath_truncate($hash, $codeDigits);
307
+        }
296 308
              
297 309
         return $result;
298 310
     }
Please login to merge, or discard this patch.
library/tiqr/Tiqr/StateStorage/Pdo.php 1 patch
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -123,8 +123,7 @@  discard block
 block discarded – undo
123 123
             $this->logger->notice(
124 124
                 sprintf("Deleted %d expired keys", $deletedRows)
125 125
             );
126
-        }
127
-        catch (Exception $e) {
126
+        } catch (Exception $e) {
128 127
             $this->logger->error(
129 128
                 sprintf("Deleting expired keys failed: %s", $e->getMessage()),
130 129
                 array('exception', $e)
@@ -157,8 +156,7 @@  discard block
 block discarded – undo
157 156
         }
158 157
         try {
159 158
             $sth->execute(array(serialize($value), $expire, $key));
160
-        }
161
-        catch (Exception $e) {
159
+        } catch (Exception $e) {
162 160
             $this->logger->error(
163 161
                 sprintf('Unable to store key "%s" in PDO StateStorage', $key),
164 162
                 array('exception' => $e)
@@ -178,8 +176,7 @@  discard block
 block discarded – undo
178 176
         try {
179 177
             $sth = $this->handle->prepare("DELETE FROM " . $this->tablename . " WHERE `key` = ?");
180 178
             $sth->execute(array($key));
181
-        }
182
-        catch (Exception $e) {
179
+        } catch (Exception $e) {
183 180
             $this->logger->error(
184 181
                 sprintf('Error deleting key "%s" from PDO StateStorage', $key),
185 182
                 array('exception' => $e)
@@ -208,8 +205,7 @@  discard block
 block discarded – undo
208 205
         try {
209 206
             $sth = $this->handle->prepare('SELECT `value` FROM ' . $this->tablename . ' WHERE `key` = ? AND (`expire` >= ? OR `expire` = 0)');
210 207
             $sth->execute(array($key, time()));
211
-        }
212
-        catch (Exception $e) {
208
+        } catch (Exception $e) {
213 209
             $this->logger->error(
214 210
                 sprintf('Error getting value for key "%s" from PDO StateStorage', $key),
215 211
                 array('exception' => $e)
@@ -239,8 +235,7 @@  discard block
 block discarded – undo
239 235
             // Retrieve a random row from the table, this checks that the table exists and is readable
240 236
             $sth = $this->handle->prepare('SELECT `value`, `key`, `expire` FROM ' . $this->tablename . ' LIMIT 1');
241 237
             $sth->execute();
242
-        }
243
-        catch (Exception $e) {
238
+        } catch (Exception $e) {
244 239
             $statusMessage = sprintf('Error performing health check on PDO StateStorage: %s', $e->getMessage());
245 240
             return false;
246 241
         }
Please login to merge, or discard this patch.
library/tiqr/Tiqr/UserStorage/Pdo.php 1 patch
Braces   +7 added lines, -14 removed lines patch added patch discarded remove patch
@@ -119,8 +119,7 @@  discard block
 block discarded – undo
119 119
                 throw new RuntimeException('Unexpected return type');
120 120
             }
121 121
             return $res;
122
-        }
123
-        catch (Exception $e) {
122
+        } catch (Exception $e) {
124 123
             $this->logger->error('PDO error getting user', array('exception' => $e, 'userId' => $userId, 'columnName'=>$columnName));
125 124
             throw ReadWriteException::fromOriginalException($e);
126 125
         }
@@ -158,8 +157,7 @@  discard block
 block discarded – undo
158 157
                 throw new RuntimeException('Unexpected return type');
159 158
             }
160 159
             return (int)$res;
161
-        }
162
-        catch (Exception $e) {
160
+        } catch (Exception $e) {
163 161
             $this->logger->error('PDO error getting user', array('exception' => $e, 'userId' => $userId, 'columnName'=>$columnName));
164 162
             throw ReadWriteException::fromOriginalException($e);
165 163
         }
@@ -186,8 +184,7 @@  discard block
 block discarded – undo
186 184
                     throw new RuntimeException('User not found');
187 185
                 }
188 186
             }
189
-        }
190
-        catch (Exception $e) {
187
+        } catch (Exception $e) {
191 188
             $this->logger->error('PDO error updating user', array('exception' => $e, 'userId' => $userId, 'columnName'=>$columnName));
192 189
             throw ReadWriteException::fromOriginalException($e);
193 190
         }
@@ -214,8 +211,7 @@  discard block
 block discarded – undo
214 211
                     throw new RuntimeException('User not found');
215 212
                 }
216 213
             }
217
-        }
218
-        catch (Exception $e) {
214
+        } catch (Exception $e) {
219 215
             $this->logger->error('PDO error updating user', array('exception' => $e, 'userId' => $userId, 'columnName'=>$columnName));
220 216
             throw ReadWriteException::fromOriginalException($e);
221 217
         }
@@ -232,8 +228,7 @@  discard block
 block discarded – undo
232 228
         try {
233 229
             $sth = $this->handle->prepare("INSERT INTO ".$this->tablename." (displayname,userid) VALUES (?,?)");
234 230
             $sth->execute(array($displayName, $userId));
235
-        }
236
-        catch (Exception $e) {
231
+        } catch (Exception $e) {
237 232
             $this->logger->error(sprintf('Error creating user "%s"', $userId), array('exception'=>$e));
238 233
             throw new ReadWriteException('The user could not be saved in the user storage (PDO)');
239 234
         }
@@ -248,8 +243,7 @@  discard block
 block discarded – undo
248 243
             $sth = $this->handle->prepare("SELECT userid FROM ".$this->tablename." WHERE userid = ?");
249 244
             $sth->execute(array($userId));
250 245
             return (false !== $sth->fetchColumn());
251
-        }
252
-        catch (Exception $e) {
246
+        } catch (Exception $e) {
253 247
             $this->logger->error('PDO error checking user exists', array('exception'=>$e, 'userId'=>$userId));
254 248
             throw ReadWriteException::fromOriginalException($e);
255 249
         }
@@ -382,8 +376,7 @@  discard block
 block discarded – undo
382 376
         try {
383 377
             $sth = $this->handle->prepare('SELECT displayname, notificationtype, notificationaddress, loginattempts, tmpblockattempts, blocked, tmpblocktimestamp FROM '.$this->tablename.' LIMIT 1');
384 378
             $sth->execute();
385
-        }
386
-        catch (Exception $e) {
379
+        } catch (Exception $e) {
387 380
             $statusMessage = "Error reading from UserStorage_PDO: ". $e->getMessage();
388 381
             return false;
389 382
         }
Please login to merge, or discard this patch.
library/tiqr/Tiqr/UserStorage/FileTrait.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -74,7 +74,9 @@
 block discarded – undo
74 74
      */
75 75
     public function getPath(): string
76 76
     {
77
-        if (substr($this->path, -1)!="/") return $this->path."/";
77
+        if (substr($this->path, -1)!="/") {
78
+            return $this->path."/";
79
+        }
78 80
         return $this->path;
79 81
     }
80 82
 
Please login to merge, or discard this patch.