@@ -86,8 +86,7 @@ discard block |
||
86 | 86 | $sth = $this->handle->prepare('SELECT userid FROM ' . $this->tableName . ' WHERE userid = ?'); |
87 | 87 | $sth->execute(array($userId)); |
88 | 88 | return (false !== $sth->fetchColumn()); |
89 | - } |
|
90 | - catch (Exception $e) { |
|
89 | + } catch (Exception $e) { |
|
91 | 90 | $this->logger->error('PDO error checking user exists', array('exception'=>$e, 'userId'=>$userId)); |
92 | 91 | throw ReadWriteException::fromOriginalException($e); |
93 | 92 | } |
@@ -111,8 +110,7 @@ discard block |
||
111 | 110 | $this->logger->error(sprintf('No result getting secret for user "%s"', $userId)); |
112 | 111 | throw new RuntimeException('User not found'); |
113 | 112 | } |
114 | - } |
|
115 | - catch (Exception $e) { |
|
113 | + } catch (Exception $e) { |
|
116 | 114 | $this->logger->error('PDO error getting user', array('exception' => $e, 'userId' => $userId)); |
117 | 115 | throw ReadWriteException::fromOriginalException($e); |
118 | 116 | } |
@@ -146,8 +144,7 @@ discard block |
||
146 | 144 | $sth = $this->handle->prepare('INSERT INTO ' . $this->tableName . ' (secret,userid) VALUES (?,?)'); |
147 | 145 | } |
148 | 146 | $sth->execute(array($secret, $userId)); |
149 | - } |
|
150 | - catch (Exception $e) { |
|
147 | + } catch (Exception $e) { |
|
151 | 148 | $this->logger->error( |
152 | 149 | sprintf('Unable to persist user secret for user "%s" in user secret storage (PDO)', $userId), |
153 | 150 | array('exception'=>$e) |
@@ -74,7 +74,9 @@ |
||
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 | } |
@@ -36,8 +36,7 @@ |
||
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 | } |
@@ -110,8 +110,7 @@ discard block |
||
110 | 110 | throw new RuntimeException('Unexpected return type'); |
111 | 111 | } |
112 | 112 | return $res; |
113 | - } |
|
114 | - catch (Exception $e) { |
|
113 | + } catch (Exception $e) { |
|
115 | 114 | $this->logger->error('PDO error getting user', array('exception' => $e, 'userId' => $userId, 'columnName'=>$columnName)); |
116 | 115 | throw ReadWriteException::fromOriginalException($e); |
117 | 116 | } |
@@ -149,8 +148,7 @@ discard block |
||
149 | 148 | throw new RuntimeException('Unexpected return type'); |
150 | 149 | } |
151 | 150 | return (int)$res; |
152 | - } |
|
153 | - catch (Exception $e) { |
|
151 | + } catch (Exception $e) { |
|
154 | 152 | $this->logger->error('PDO error getting user', array('exception' => $e, 'userId' => $userId, 'columnName'=>$columnName)); |
155 | 153 | throw ReadWriteException::fromOriginalException($e); |
156 | 154 | } |
@@ -177,8 +175,7 @@ discard block |
||
177 | 175 | throw new RuntimeException('User not found'); |
178 | 176 | } |
179 | 177 | } |
180 | - } |
|
181 | - catch (Exception $e) { |
|
178 | + } catch (Exception $e) { |
|
182 | 179 | $this->logger->error('PDO error updating user', array('exception' => $e, 'userId' => $userId, 'columnName'=>$columnName)); |
183 | 180 | throw ReadWriteException::fromOriginalException($e); |
184 | 181 | } |
@@ -205,8 +202,7 @@ discard block |
||
205 | 202 | throw new RuntimeException('User not found'); |
206 | 203 | } |
207 | 204 | } |
208 | - } |
|
209 | - catch (Exception $e) { |
|
205 | + } catch (Exception $e) { |
|
210 | 206 | $this->logger->error('PDO error updating user', array('exception' => $e, 'userId' => $userId, 'columnName'=>$columnName)); |
211 | 207 | throw ReadWriteException::fromOriginalException($e); |
212 | 208 | } |
@@ -223,8 +219,7 @@ discard block |
||
223 | 219 | try { |
224 | 220 | $sth = $this->handle->prepare("INSERT INTO ".$this->tablename." (displayname,userid) VALUES (?,?)"); |
225 | 221 | $sth->execute(array($displayName, $userId)); |
226 | - } |
|
227 | - catch (Exception $e) { |
|
222 | + } catch (Exception $e) { |
|
228 | 223 | $this->logger->error(sprintf('Error creating user "%s"', $userId), array('exception'=>$e)); |
229 | 224 | throw new ReadWriteException('The user could not be saved in the user storage (PDO)'); |
230 | 225 | } |
@@ -239,8 +234,7 @@ discard block |
||
239 | 234 | $sth = $this->handle->prepare("SELECT userid FROM ".$this->tablename." WHERE userid = ?"); |
240 | 235 | $sth->execute(array($userId)); |
241 | 236 | return (false !== $sth->fetchColumn()); |
242 | - } |
|
243 | - catch (Exception $e) { |
|
237 | + } catch (Exception $e) { |
|
244 | 238 | $this->logger->error('PDO error checking user exists', array('exception'=>$e, 'userId'=>$userId)); |
245 | 239 | throw ReadWriteException::fromOriginalException($e); |
246 | 240 | } |
@@ -28,8 +28,7 @@ |
||
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'); |
@@ -41,8 +41,9 @@ |
||
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": |
@@ -287,8 +287,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -42,8 +42,9 @@ |
||
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": |
@@ -123,8 +123,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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) |