Passed
Pull Request — develop (#43)
by Pieter van der
02:56
created
library/tiqr/Tiqr/Service.php 3 patches
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -571,17 +571,17 @@  discard block
 block discarded – undo
571 571
         }
572 572
 
573 573
         $metadata = array("service"=>
574
-                               array("displayName"       => $this->_name,
575
-                                     "identifier"        => $this->_identifier,
576
-                                     "logoUrl"           => $this->_logoUrl,
577
-                                     "infoUrl"           => $this->_infoUrl,
578
-                                     "authenticationUrl" => $authenticationUrl,
579
-                                     "ocraSuite"         => $this->_ocraSuite,
580
-                                     "enrollmentUrl"     => $enrollmentUrl
581
-                               ),
582
-                          "identity"=>
583
-                               array("identifier" =>$data["userId"],
584
-                                     "displayName"=>$data["displayName"]));
574
+                                array("displayName"       => $this->_name,
575
+                                        "identifier"        => $this->_identifier,
576
+                                        "logoUrl"           => $this->_logoUrl,
577
+                                        "infoUrl"           => $this->_infoUrl,
578
+                                        "authenticationUrl" => $authenticationUrl,
579
+                                        "ocraSuite"         => $this->_ocraSuite,
580
+                                        "enrollmentUrl"     => $enrollmentUrl
581
+                                ),
582
+                            "identity"=>
583
+                                array("identifier" =>$data["userId"],
584
+                                        "displayName"=>$data["displayName"]));
585 585
 
586 586
         $this->_unsetStateValue(self::PREFIX_ENROLLMENT, $enrollmentKey);
587 587
 
@@ -611,28 +611,28 @@  discard block
 block discarded – undo
611 611
      */
612 612
     public function getEnrollmentSecret(string $enrollmentKey): string
613 613
     {
614
-         $data = $this->_getStateValue(self::PREFIX_ENROLLMENT, $enrollmentKey);
615
-         if (!is_array($data)) {
616
-             $this->logger->error('getEnrollmentSecret: enrollment key not found');
617
-             throw new RuntimeException('enrollment key not found');
618
-         }
619
-         $userId = $data["userId"] ?? NULL;
620
-         $sessionId = $data["sessionId"] ?? NULL;
621
-         if (!is_string($userId) || !(is_string($sessionId))) {
622
-             throw new RuntimeException('getEnrollmentSecret: invalid enrollment data');
623
-         }
624
-         $enrollmentData = [
625
-             "userId" => $userId,
626
-             "sessionId" => $sessionId
627
-         ];
628
-         $enrollmentSecret = $this->_uniqueSessionKey();
629
-         $this->_setStateValue(
630
-             self::PREFIX_ENROLLMENT_SECRET,
631
-             $enrollmentSecret,
632
-             $enrollmentData,
633
-             self::ENROLLMENT_EXPIRE
634
-         );
635
-         return $enrollmentSecret;
614
+            $data = $this->_getStateValue(self::PREFIX_ENROLLMENT, $enrollmentKey);
615
+            if (!is_array($data)) {
616
+                $this->logger->error('getEnrollmentSecret: enrollment key not found');
617
+                throw new RuntimeException('enrollment key not found');
618
+            }
619
+            $userId = $data["userId"] ?? NULL;
620
+            $sessionId = $data["sessionId"] ?? NULL;
621
+            if (!is_string($userId) || !(is_string($sessionId))) {
622
+                throw new RuntimeException('getEnrollmentSecret: invalid enrollment data');
623
+            }
624
+            $enrollmentData = [
625
+                "userId" => $userId,
626
+                "sessionId" => $sessionId
627
+            ];
628
+            $enrollmentSecret = $this->_uniqueSessionKey();
629
+            $this->_setStateValue(
630
+                self::PREFIX_ENROLLMENT_SECRET,
631
+                $enrollmentSecret,
632
+                $enrollmentData,
633
+                self::ENROLLMENT_EXPIRE
634
+            );
635
+            return $enrollmentSecret;
636 636
     }
637 637
 
638 638
     /**
Please login to merge, or discard this patch.
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
     // INVALID_USERID: The client authenticated a different user than the server expected. This error is returned when
119 119
     // the application stated an authentication session specifying the userId and later during the authentication
120 120
     // provides a different userId
121
-    const AUTH_RESULT_INVALID_USERID    = 5;
121
+    const AUTH_RESULT_INVALID_USERID = 5;
122 122
     
123 123
     /**
124 124
      * The default OCRA Suite (RFC 6287) to use for authentication in Tiqr
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
      * @param int $version The tiqr protocol version to use (defaults to the latest)
245 245
      * @throws Exception
246 246
      */
247
-    public function __construct(LoggerInterface $logger, array $options=array(), int $version = 2)
247
+    public function __construct(LoggerInterface $logger, array $options = array(), int $version = 2)
248 248
     {
249 249
         $this->_options = $options; // Used to later get settings for Tiqr_Message_*
250 250
         $this->logger = $logger;
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
 
362 362
             $this->logger->info(sprintf('Creating and sending a %s push notification', $notificationType));
363 363
             $message->setId(time());
364
-            $message->setText("Please authenticate for " . $this->_name);
364
+            $message->setText("Please authenticate for ".$this->_name);
365 365
             $message->setAddress($notificationAddress);
366 366
             $message->setCustomProperty('challenge', $this->_getChallengeUrl($sessionKey));
367 367
             $message->send();
@@ -407,13 +407,13 @@  discard block
 block discarded – undo
407 407
      * @return string The authentication sessionKey
408 408
      * @throws Exception when starting the authentication session failed
409 409
      */
410
-    public function startAuthenticationSession(string $userId="", string $sessionId="", string $spIdentifier=""): string
410
+    public function startAuthenticationSession(string $userId = "", string $sessionId = "", string $spIdentifier = ""): string
411 411
     {
412
-        if ($sessionId=="") {
412
+        if ($sessionId == "") {
413 413
             $sessionId = session_id();
414 414
         }
415 415
 
416
-        if ($spIdentifier=="") {
416
+        if ($spIdentifier == "") {
417 417
             $spIdentifier = $this->_identifier;
418 418
         }
419 419
 
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
         
423 423
         $data = array("sessionId"=>$sessionId, "challenge"=>$challenge, "spIdentifier" => $spIdentifier);
424 424
         
425
-        if ($userId!="") {
425
+        if ($userId != "") {
426 426
             $data["userId"] = $userId;
427 427
         }
428 428
         
@@ -446,9 +446,9 @@  discard block
 block discarded – undo
446 446
      * @return String The enrollment key
447 447
      * @throws Exception when start the enrollement session failed
448 448
      */
449
-    public function startEnrollmentSession(string $userId, string $displayName, string $sessionId=""): string
449
+    public function startEnrollmentSession(string $userId, string $displayName, string $sessionId = ""): string
450 450
     {
451
-        if ($sessionId=="") {
451
+        if ($sessionId == "") {
452 452
             $sessionId = session_id();
453 453
         }
454 454
         $enrollmentKey = $this->_uniqueSessionKey();
@@ -468,9 +468,9 @@  discard block
 block discarded – undo
468 468
      * @param string $sessionId The application's session identifier (defaults to php session)
469 469
      * @throws Exception when resetting the session failed
470 470
      */
471
-    public function resetEnrollmentSession(string $sessionId=""): void
471
+    public function resetEnrollmentSession(string $sessionId = ""): void
472 472
     {
473
-        if ($sessionId=="") {
473
+        if ($sessionId == "") {
474 474
             $sessionId = session_id();
475 475
         }
476 476
 
@@ -505,9 +505,9 @@  discard block
 block discarded – undo
505 505
      *
506 506
      * @throws Exception when an error communicating with the state storage backend was detected
507 507
      */
508
-    public function getEnrollmentStatus(string $sessionId=""): int
508
+    public function getEnrollmentStatus(string $sessionId = ""): int
509 509
     { 
510
-        if ($sessionId=="") {
510
+        if ($sessionId == "") {
511 511
             $sessionId = session_id(); 
512 512
         }
513 513
         $status = $this->_getStateValue(self::PREFIX_ENROLLMENT_STATUS, $sessionId);
@@ -660,7 +660,7 @@  discard block
 block discarded – undo
660 660
             if (NULL === $data) {
661 661
                 throw new RuntimeException('Enrollment secret not found');
662 662
             }
663
-            if ( !is_array($data) || !is_string($data["userId"] ?? NULL)) {
663
+            if (!is_array($data) || !is_string($data["userId"] ?? NULL)) {
664 664
                 throw new RuntimeException('Invalid enrollment data');
665 665
             }
666 666
 
@@ -700,7 +700,7 @@  discard block
 block discarded – undo
700 700
                 $this->_setEnrollmentStatus($data["sessionId"], self::ENROLLMENT_STATUS_FINALIZED);
701 701
             } else {
702 702
                 $this->logger->error(
703
-                    'Enrollment status is not finalized, enrollmentsecret was not found in state storage. ' .
703
+                    'Enrollment status is not finalized, enrollmentsecret was not found in state storage. '.
704 704
                     'Warning! the method will still return "true" as a result.'
705 705
                 );
706 706
             }
@@ -758,9 +758,9 @@  discard block
 block discarded – undo
758 758
             throw $e;
759 759
         }
760 760
 
761
-        $sessionId = $state["sessionId"] ?? NULL;   // Application's sessionId
762
-        $challenge = $state["challenge"] ?? NULL;   // The challenge we sent to the Tiqr client
763
-        if (!is_string($sessionId) || (!is_string($challenge)) ) {
761
+        $sessionId = $state["sessionId"] ?? NULL; // Application's sessionId
762
+        $challenge = $state["challenge"] ?? NULL; // The challenge we sent to the Tiqr client
763
+        if (!is_string($sessionId) || (!is_string($challenge))) {
764 764
             throw new RuntimeException('Invalid state for state storage');
765 765
         }
766 766
 
@@ -769,7 +769,7 @@  discard block
 block discarded – undo
769 769
         $challengeUserId = $state["userId"] ?? NULL;
770 770
 
771 771
         // If the application requested a specific userId, verify that that is that userId that we're now authenticating
772
-        if ($challengeUserId!==NULL && ($userId !== $challengeUserId)) {
772
+        if ($challengeUserId !== NULL && ($userId !== $challengeUserId)) {
773 773
             $this->logger->error(
774 774
                 sprintf('Authentication failed: the requested userId "%s" does not match userId "%s" that is being authenticated',
775 775
                 $challengeUserId, $userId)
@@ -817,9 +817,9 @@  discard block
 block discarded – undo
817 817
      *
818 818
      * @throws Exception when there was an error communicating with the storage backed
819 819
      */
820
-    public function logout(string $sessionId=""): void
820
+    public function logout(string $sessionId = ""): void
821 821
     {
822
-        if ($sessionId=="") {
822
+        if ($sessionId == "") {
823 823
             $sessionId = session_id(); 
824 824
         }
825 825
         
@@ -859,9 +859,9 @@  discard block
 block discarded – undo
859 859
      *
860 860
      * Does not throw
861 861
      */
862
-    public function getAuthenticatedUser(string $sessionId=""): ?string
862
+    public function getAuthenticatedUser(string $sessionId = ""): ?string
863 863
     {
864
-        if ($sessionId=="") {
864
+        if ($sessionId == "") {
865 865
             $this->logger->debug('Using the PHP session id, as no session id was provided');
866 866
             $sessionId = session_id(); 
867 867
         }
@@ -905,22 +905,22 @@  discard block
 block discarded – undo
905 905
         $challenge = $state["challenge"] ?? '';
906 906
         $spIdentifier = $state["spIdentifier"] ?? '';
907 907
 
908
-        if ( (strpos($this->_protocolAuth, 'https://') === 0) || (strpos($this->_protocolAuth, 'http://') === 0) ) {
908
+        if ((strpos($this->_protocolAuth, 'https://') === 0) || (strpos($this->_protocolAuth, 'http://') === 0)) {
909 909
             // Create universal Link
910
-            $parameters=array();
910
+            $parameters = array();
911 911
             if (!is_null($userId)) {
912
-                $parameters[]='u='.urlencode($userId);
912
+                $parameters[] = 'u='.urlencode($userId);
913 913
             }
914
-            $parameters[]='s='.urlencode($sessionKey);
915
-            $parameters[]='q='.urlencode($challenge);
916
-            $parameters[]='i='.urlencode($this->getIdentifier());
917
-            $parameters[]='v='.urlencode($this->_protocolVersion);
914
+            $parameters[] = 's='.urlencode($sessionKey);
915
+            $parameters[] = 'q='.urlencode($challenge);
916
+            $parameters[] = 'i='.urlencode($this->getIdentifier());
917
+            $parameters[] = 'v='.urlencode($this->_protocolVersion);
918 918
             return $this->_protocolAuth.'?'.implode('&', $parameters);
919 919
         }
920 920
 
921 921
         // Create custom URL scheme
922 922
         // Last bit is the spIdentifier
923
-        return $this->_protocolAuth."://".(!is_null($userId)?urlencode($userId).'@':'').$this->getIdentifier()."/".$sessionKey."/".$challenge."/".urlencode($spIdentifier)."/".$this->_protocolVersion;
923
+        return $this->_protocolAuth."://".(!is_null($userId) ?urlencode($userId).'@' : '').$this->getIdentifier()."/".$sessionKey."/".$challenge."/".urlencode($spIdentifier)."/".$this->_protocolVersion;
924 924
     }
925 925
 
926 926
     /**
@@ -931,7 +931,7 @@  discard block
 block discarded – undo
931 931
     {
932 932
         // The are two formats see: https://tiqr.org/technical/protocol/
933 933
 
934
-        if ( (strpos($this->_protocolEnroll, 'https://') === 0) || (strpos($this->_protocolEnroll, 'http://') === 0) ) {
934
+        if ((strpos($this->_protocolEnroll, 'https://') === 0) || (strpos($this->_protocolEnroll, 'http://') === 0)) {
935 935
             // Create universal Link
936 936
             return $this->_protocolEnroll.'?metadata='.urlencode($metadataUrl);
937 937
         }
@@ -950,7 +950,7 @@  discard block
 block discarded – undo
950 950
     protected function _uniqueSessionKey(): string
951 951
     {
952 952
 
953
-        return bin2hex( Tiqr_Random::randomBytes(self::SESSION_KEY_LENGTH_BYTES) );
953
+        return bin2hex(Tiqr_Random::randomBytes(self::SESSION_KEY_LENGTH_BYTES));
954 954
     }
955 955
     
956 956
     /**
@@ -981,7 +981,7 @@  discard block
 block discarded – undo
981 981
      */
982 982
     protected function _setStateValue(string $key_prefix, string $key, $value, int $expire): void {
983 983
         $this->_stateStorage->setValue(
984
-            $key_prefix . $this->_hashKey($key),
984
+            $key_prefix.$this->_hashKey($key),
985 985
             $value,
986 986
             $expire
987 987
         );
@@ -998,7 +998,7 @@  discard block
 block discarded – undo
998 998
 
999 999
     protected function _getStateValue(string $key_prefix, string $key) {
1000 1000
         return $this->_stateStorage->getValue(
1001
-            $key_prefix . $this->_hashKey($key)
1001
+            $key_prefix.$this->_hashKey($key)
1002 1002
         );
1003 1003
     }
1004 1004
 
@@ -1012,7 +1012,7 @@  discard block
 block discarded – undo
1012 1012
      */
1013 1013
     protected function _unsetStateValue(string $key_prefix, string $key): void {
1014 1014
         $this->_stateStorage->unsetValue(
1015
-            $key_prefix . $this->_hashKey($key)
1015
+            $key_prefix.$this->_hashKey($key)
1016 1016
         );
1017 1017
     }
1018 1018
 
Please login to merge, or discard this patch.
Braces   +5 added lines, -5 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
     }
@@ -511,7 +510,9 @@  discard block
 block discarded – undo
511 510
             $sessionId = session_id(); 
512 511
         }
513 512
         $status = $this->_getStateValue(self::PREFIX_ENROLLMENT_STATUS, $sessionId);
514
-        if (is_null($status)) return self::ENROLLMENT_STATUS_IDLE;
513
+        if (is_null($status)) {
514
+            return self::ENROLLMENT_STATUS_IDLE;
515
+        }
515 516
         return $status;
516 517
     }
517 518
         
@@ -868,8 +869,7 @@  discard block
 block discarded – undo
868 869
         
869 870
         try {
870 871
             return $this->_getStateValue("authenticated_", $sessionId);
871
-        }
872
-        catch (Exception $e) {
872
+        } catch (Exception $e) {
873 873
             $this->logger->error('getAuthenticatedUser failed', array('exception'=>$e));
874 874
             return NULL;
875 875
         }
Please login to merge, or discard this patch.
library/tiqr/Tiqr/OcraService/Tiqr.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-require_once __DIR__ . '/../OATH/OCRA.php';
3
+require_once __DIR__.'/../OATH/OCRA.php';
4 4
 
5 5
 /**
6 6
  * This file is part of the tiqr project.
Please login to merge, or discard this patch.
library/tiqr/Tiqr/UserStorage/Pdo.php 3 patches
Indentation   -2 removed lines patch added patch discarded remove patch
@@ -30,13 +30,11 @@
 block discarded – undo
30 30
     notificationtype varchar(10),
31 31
     notificationaddress varchar(64)
32 32
 );
33
-
34 33
  *
35 34
  * In version 3.0 the format of the tmpblocktimestamp was changed from a datetime format to an integer.
36 35
  * Because it holds a unix timestamp a 64-bit (8-byte) integer. To upgrade the user table to the new format use:
37 36
 
38 37
 ALTER TABLE user MODIFY tmpblocktimestamp BIGINT;
39
-
40 38
  */
41 39
 
42 40
 use Psr\Log\LoggerInterface;
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -89,21 +89,21 @@  discard block
 block discarded – undo
89 89
      */
90 90
     private function _getStringValue(string $columnName, string $userId): string
91 91
     {
92
-        if ( !in_array($columnName, $this->_allowedStringColumns) ) {
92
+        if (!in_array($columnName, $this->_allowedStringColumns)) {
93 93
             throw new InvalidArgumentException('Unsupported column name');
94 94
         }
95 95
 
96 96
         try {
97
-            $sth = $this->handle->prepare('SELECT ' . $columnName . ' FROM ' . $this->tablename . ' WHERE userid = ?');
97
+            $sth = $this->handle->prepare('SELECT '.$columnName.' FROM '.$this->tablename.' WHERE userid = ?');
98 98
             $sth->execute(array($userId));
99
-            $res=$sth->fetchColumn();
99
+            $res = $sth->fetchColumn();
100 100
             if ($res === false) {
101 101
                 // No result
102 102
                 $this->logger->error(sprintf('No result getting "%s" for user "%s"', $columnName, $userId));
103 103
                 throw new RuntimeException('User not found');
104 104
             }
105 105
             if ($res === NULL) {
106
-                return '';  // Value unset
106
+                return ''; // Value unset
107 107
             }
108 108
             if (!is_string($res)) {
109 109
                 $this->logger->error(sprintf('Expected string type while getting "%s" for user "%s"', $columnName, $userId));
@@ -127,28 +127,28 @@  discard block
 block discarded – undo
127 127
      */
128 128
     private function _getIntValue(string $columnName, string $userId): int
129 129
     {
130
-        if ( !in_array($columnName, $this->_allowedIntColumns) ) {
130
+        if (!in_array($columnName, $this->_allowedIntColumns)) {
131 131
             throw new InvalidArgumentException('Unsupported column name');
132 132
         }
133 133
 
134 134
         try {
135
-            $sth = $this->handle->prepare('SELECT ' . $columnName . ' FROM ' . $this->tablename . ' WHERE userid = ?');
135
+            $sth = $this->handle->prepare('SELECT '.$columnName.' FROM '.$this->tablename.' WHERE userid = ?');
136 136
             $sth->execute(array($userId));
137
-            $res=$sth->fetchColumn();
137
+            $res = $sth->fetchColumn();
138 138
             if ($res === false) {
139 139
                 // No result
140 140
                 $this->logger->error(sprintf('No result getting "%s" for user "%s"', $columnName, $userId));
141 141
                 throw new RuntimeException('User not found');
142 142
             }
143 143
             if ($res === NULL) {
144
-                return 0;  // Value unset
144
+                return 0; // Value unset
145 145
             }
146 146
             // Return type for integers depends on the PDO driver, can be string
147 147
             if (!is_numeric($res)) {
148 148
                 $this->logger->error(sprintf('Expected int type while getting "%s" for user "%s"', $columnName, $userId));
149 149
                 throw new RuntimeException('Unexpected return type');
150 150
             }
151
-            return (int)$res;
151
+            return (int) $res;
152 152
         }
153 153
         catch (Exception $e) {
154 154
             $this->logger->error('PDO error getting user', array('exception' => $e, 'userId' => $userId, 'columnName'=>$columnName));
@@ -165,11 +165,11 @@  discard block
 block discarded – undo
165 165
      */
166 166
     private function _setStringValue(string $columnName, string $userId, string $value): void
167 167
     {
168
-        if ( !in_array($columnName, $this->_allowedStringColumns) ) {
168
+        if (!in_array($columnName, $this->_allowedStringColumns)) {
169 169
             throw new InvalidArgumentException('Unsupported column name');
170 170
         }
171 171
         try {
172
-            $sth = $this->handle->prepare('UPDATE ' . $this->tablename . ' SET ' . $columnName . ' = ? WHERE userid = ?');
172
+            $sth = $this->handle->prepare('UPDATE '.$this->tablename.' SET '.$columnName.' = ? WHERE userid = ?');
173 173
             $sth->execute(array($value, $userId));
174 174
             if ($sth->rowCount() == 0) {
175 175
                 // Required for mysql which only returns the number of rows that were actually updated
@@ -193,11 +193,11 @@  discard block
 block discarded – undo
193 193
      */
194 194
     private function _setIntValue(string $columnName, string $userId, int $value): void
195 195
     {
196
-        if ( !in_array($columnName, $this->_allowedIntColumns) ) {
196
+        if (!in_array($columnName, $this->_allowedIntColumns)) {
197 197
             throw new InvalidArgumentException('Unsupported column name');
198 198
         }
199 199
         try {
200
-            $sth = $this->handle->prepare('UPDATE ' . $this->tablename . ' SET ' . $columnName . ' = ? WHERE userid = ?');
200
+            $sth = $this->handle->prepare('UPDATE '.$this->tablename.' SET '.$columnName.' = ? WHERE userid = ?');
201 201
             $sth->execute(array($value, $userId));
202 202
             if ($sth->rowCount() == 0) {
203 203
                 // Required for mysql which only returns the number of rows that were actually updated
@@ -309,17 +309,17 @@  discard block
 block discarded – undo
309 309
     {
310 310
         // Check for blocked
311 311
         if ($this->_getIntValue('blocked', $userId) != 0) {
312
-            return true;   // Blocked
312
+            return true; // Blocked
313 313
         }
314 314
 
315 315
         if (0 == $tempBlockDuration) {
316
-            return false;   // No check for temporary block
316
+            return false; // No check for temporary block
317 317
         }
318 318
 
319 319
         // Check for temporary block
320 320
         $timestamp = $this->getTemporaryBlockTimestamp($userId);
321 321
         // if no temporary block timestamp is set or if the temporary block is expired, return false
322
-        if ( 0 == $timestamp || ($timestamp + $tempBlockDuration * 60) < time()) {
322
+        if (0 == $timestamp || ($timestamp + $tempBlockDuration * 60) < time()) {
323 323
             return false;
324 324
         }
325 325
         return true;
Please login to merge, or discard this patch.
Braces   +6 added lines, -12 removed lines patch added patch discarded remove patch
@@ -110,8 +110,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
         }
Please login to merge, or discard this patch.