Passed
Pull Request — develop (#43)
by Pieter van der
02:56
created
library/tiqr/Tiqr/Service.php 2 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.
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/UserStorage/Pdo.php 2 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.
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.