Passed
Pull Request — develop (#50)
by Pieter van der
03:28
created
library/tiqr/Tiqr/StateStorage/Pdo.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
             throw new InvalidArgumentException('Empty key not allowed');
122 122
         }
123 123
         try {
124
-            $sth = $this->handle->prepare('SELECT `key` FROM ' . $this->tablename . ' WHERE `key` = ?');
124
+            $sth = $this->handle->prepare('SELECT `key` FROM '.$this->tablename.' WHERE `key` = ?');
125 125
             $sth->execute(array($key));
126 126
             return $sth->fetchColumn() !== false;
127 127
         }
@@ -141,9 +141,9 @@  discard block
 block discarded – undo
141 141
      */
142 142
     private function cleanExpired(): void {
143 143
         try {
144
-            $sth = $this->handle->prepare("DELETE FROM " . $this->tablename . " WHERE `expire` < ? AND NOT `expire` = 0");
144
+            $sth = $this->handle->prepare("DELETE FROM ".$this->tablename." WHERE `expire` < ? AND NOT `expire` = 0");
145 145
             $sth->execute(array(time()));
146
-            $deletedRows=$sth->rowCount();
146
+            $deletedRows = $sth->rowCount();
147 147
             $this->logger->notice(
148 148
                 sprintf("Deleted %d expired keys", $deletedRows)
149 149
             );
@@ -159,12 +159,12 @@  discard block
 block discarded – undo
159 159
     /**
160 160
      * @see Tiqr_StateStorage_StateStorageInterface::setValue()
161 161
      */
162
-    public function setValue(string $key, $value, int $expire=0): void
162
+    public function setValue(string $key, $value, int $expire = 0): void
163 163
     {
164 164
         if (empty($key)) {
165 165
             throw new InvalidArgumentException('Empty key not allowed');
166 166
         }
167
-        if (((float) rand() /(float) getrandmax()) < $this->cleanupProbability) {
167
+        if (((float) rand() / (float) getrandmax()) < $this->cleanupProbability) {
168 168
             $this->cleanExpired();
169 169
         }
170 170
         if ($this->keyExists($key)) {
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
         }
175 175
         // $expire == 0 means never expire
176 176
         if ($expire != 0) {
177
-            $expire+=time();    // Store unix timestamp after which the key expires
177
+            $expire += time(); // Store unix timestamp after which the key expires
178 178
         }
179 179
         try {
180 180
             $sth->execute(array(serialize($value), $expire, $key));
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
             throw new InvalidArgumentException('Empty key not allowed');
198 198
         }
199 199
         try {
200
-            $sth = $this->handle->prepare("DELETE FROM " . $this->tablename . " WHERE `key` = ?");
200
+            $sth = $this->handle->prepare("DELETE FROM ".$this->tablename." WHERE `key` = ?");
201 201
             $sth->execute(array($key));
202 202
         }
203 203
         catch (Exception $e) {
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
         }
228 228
 
229 229
         try {
230
-            $sth = $this->handle->prepare('SELECT `value` FROM ' . $this->tablename . ' WHERE `key` = ? AND (`expire` >= ? OR `expire` = 0)');
230
+            $sth = $this->handle->prepare('SELECT `value` FROM '.$this->tablename.' WHERE `key` = ? AND (`expire` >= ? OR `expire` = 0)');
231 231
             $sth->execute(array($key, time()));
232 232
         }
233 233
         catch (Exception $e) {
@@ -241,9 +241,9 @@  discard block
 block discarded – undo
241 241
         if (false === $result) {
242 242
             // Occurs normally
243 243
             $this->logger->info(sprintf('getValue: Key "%s" not found in PDO StateStorage', $key));
244
-            return NULL;    // Key not found
244
+            return NULL; // Key not found
245 245
         }
246
-        $result=unserialize($result, array('allowed_classes' => false));
246
+        $result = unserialize($result, array('allowed_classes' => false));
247 247
         if (false === $result) {
248 248
             throw new RuntimeException(sprintf('getValue: unserialize error for key "%s" in PDO StateStorage', $key));
249 249
         }
Please login to merge, or discard this patch.
library/tiqr/Tiqr/UserSecretStorage.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@
 block discarded – undo
74 74
                 $password = $options['password'];
75 75
 
76 76
                 try {
77
-                    $handle = new PDO($dsn, $userName, $password, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION) );
77
+                    $handle = new PDO($dsn, $userName, $password, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
78 78
                 } catch (PDOException $e) {
79 79
                     $logger->error(
80 80
                         sprintf('Unable to establish a PDO connection. Error message from PDO: %s', $e->getMessage())
Please login to merge, or discard this patch.
library/tiqr/Tiqr/OcraService.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -39,10 +39,10 @@
 block discarded – undo
39 39
      * @return Tiqr_OcraService_Interface
40 40
      * @throws Exception An exception if an unknown orca service type is requested.
41 41
      */
42
-    public static function getOcraService(string $type="tiqr", array $options=array(), LoggerInterface $logger=null)
42
+    public static function getOcraService(string $type = "tiqr", array $options = array(), LoggerInterface $logger = null)
43 43
     {
44 44
         if (!$logger)
45
-            $logger=new \Psr\Log\NullLogger();
45
+            $logger = new \Psr\Log\NullLogger();
46 46
 
47 47
         switch ($type) {
48 48
             case "tiqr":
Please login to merge, or discard this patch.
library/tiqr/Tiqr/OATH/OCRAParser.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 	 */
46 46
 	private function parseOCRASuite($ocraSuite) {
47 47
 		if (!is_string($ocraSuite)) {
48
-			throw new Exception('OCRASuite not in string format: ' . var_export($ocraSuite, TRUE));
48
+			throw new Exception('OCRASuite not in string format: '.var_export($ocraSuite, TRUE));
49 49
 		}
50 50
 
51 51
 		$ocraSuite = strtoupper($ocraSuite);
@@ -53,54 +53,54 @@  discard block
 block discarded – undo
53 53
 
54 54
 		$s = explode(':', $ocraSuite);
55 55
 		if (count($s) != 3) {
56
-			throw new Exception('Invalid OCRASuite format: ' . var_export($ocraSuite, TRUE));
56
+			throw new Exception('Invalid OCRASuite format: '.var_export($ocraSuite, TRUE));
57 57
 		}
58 58
 
59 59
 		$algo = explode('-', $s[0]);
60 60
 		if (count($algo) != 2) {
61
-			throw new Exception('Invalid OCRA version: ' . var_export($s[0], TRUE));
61
+			throw new Exception('Invalid OCRA version: '.var_export($s[0], TRUE));
62 62
 		}
63 63
 
64 64
 		if ($algo[0] !== 'OCRA') {
65
-			throw new Exception('Unsupported OCRA algorithm: ' . var_export($algo[0], TRUE));
65
+			throw new Exception('Unsupported OCRA algorithm: '.var_export($algo[0], TRUE));
66 66
 		}
67 67
 
68 68
 		if ($algo[1] !== '1') {
69
-			throw new Exception('Unsupported OCRA version: ' . var_export($algo[1], TRUE));
69
+			throw new Exception('Unsupported OCRA version: '.var_export($algo[1], TRUE));
70 70
 		}
71 71
 		$this->OCRAVersion = $algo[1];
72 72
 
73 73
 		$cf = explode('-', $s[1]);
74 74
 		if (count($cf) != 3) {
75
-			throw new Exception('Invalid OCRA suite crypto function: ' . var_export($s[1], TRUE));
75
+			throw new Exception('Invalid OCRA suite crypto function: '.var_export($s[1], TRUE));
76 76
 		}
77 77
 
78 78
 		if ($cf[0] !== 'HOTP') {
79
-			throw new Exception('Unsupported OCRA suite crypto function: ' . var_export($cf[0], TRUE));
79
+			throw new Exception('Unsupported OCRA suite crypto function: '.var_export($cf[0], TRUE));
80 80
 		}
81 81
 		$this->CryptoFunctionType = $cf[0];
82 82
 
83 83
 		if (!array_key_exists($cf[1], $this->supportedHashFunctions)) {
84
-			throw new Exception('Unsupported hash function in OCRA suite crypto function: ' . var_export($cf[1], TRUE));
84
+			throw new Exception('Unsupported hash function in OCRA suite crypto function: '.var_export($cf[1], TRUE));
85 85
 		}
86 86
 		$this->CryptoFunctionHash = $cf[1];
87 87
 		$this->CryptoFunctionHashLength = $this->supportedHashFunctions[$cf[1]];
88 88
 
89 89
 		if (!preg_match('/^\d+$/', $cf[2]) || (($cf[2] < 4 || $cf[2] > 10) && $cf[2] != 0)) {
90
-			throw new Exception('Invalid OCRA suite crypto function truncation length: ' . var_export($cf[2], TRUE));
90
+			throw new Exception('Invalid OCRA suite crypto function truncation length: '.var_export($cf[2], TRUE));
91 91
 		}
92 92
 		$this->CryptoFunctionTruncation = intval($cf[2]);
93 93
 
94 94
 		$di = explode('-', $s[2]);
95 95
 		if (count($cf) == 0) {
96
-			throw new Exception('Invalid OCRA suite data input: ' . var_export($s[2], TRUE));
96
+			throw new Exception('Invalid OCRA suite data input: '.var_export($s[2], TRUE));
97 97
 		}
98 98
 
99 99
 		$data_input = array();
100
-		foreach($di as $elem) {
100
+		foreach ($di as $elem) {
101 101
 			$letter = $elem[0];
102 102
 			if (array_key_exists($letter, $data_input)) {
103
-				throw new Exception('Duplicate field in OCRA suite data input: ' . var_export($elem, TRUE));
103
+				throw new Exception('Duplicate field in OCRA suite data input: '.var_export($elem, TRUE));
104 104
 			}
105 105
 			$data_input[$letter] = 1;
106 106
 
@@ -112,13 +112,13 @@  discard block
 block discarded – undo
112 112
 				} elseif (preg_match('/^Q([AHN])(\d+)$/', $elem, $match)) {
113 113
 					$q_len = intval($match[2]);
114 114
 					if ($q_len < 4 || $q_len > 64) {
115
-						throw new Exception('Invalid OCRA suite data input question length: ' . var_export($q_len, TRUE));
115
+						throw new Exception('Invalid OCRA suite data input question length: '.var_export($q_len, TRUE));
116 116
 					}
117 117
 					$this->Q = TRUE;
118 118
 					$this->QType = $match[1];
119 119
 					$this->QLength = $q_len;
120 120
 				} else {
121
-					throw new Exception('Invalid OCRA suite data input question: ' . var_export($elem, TRUE));
121
+					throw new Exception('Invalid OCRA suite data input question: '.var_export($elem, TRUE));
122 122
 				}
123 123
 			} elseif ($letter === 'P') {
124 124
 				if (strlen($elem) == 1) {
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 				} else {
127 127
 					$p_algo = substr($elem, 1);
128 128
 					if (!array_key_exists($p_algo, $this->supportedHashFunctions)) {
129
-						throw new Exception('Unsupported OCRA suite PIN hash function: ' . var_export($elem, TRUE));
129
+						throw new Exception('Unsupported OCRA suite PIN hash function: '.var_export($elem, TRUE));
130 130
 					}
131 131
 					$this->P = TRUE;
132 132
 					$this->PType = $p_algo;
@@ -138,13 +138,13 @@  discard block
 block discarded – undo
138 138
 				} elseif (preg_match('/^S(\d+)$/', $elem, $match)) {
139 139
 					$s_len = intval($match[1]);
140 140
 					if ($s_len <= 0 || $s_len > 512) {
141
-						throw new Exception('Invalid OCRA suite data input session information length: ' . var_export($s_len, TRUE));
141
+						throw new Exception('Invalid OCRA suite data input session information length: '.var_export($s_len, TRUE));
142 142
 					}
143 143
 
144 144
 					$this->S = TRUE;
145 145
 					$this->SLength = $s_len;
146 146
 				} else {
147
-					throw new Exception('Invalid OCRA suite data input session information length: ' . var_export($elem, TRUE));
147
+					throw new Exception('Invalid OCRA suite data input session information length: '.var_export($elem, TRUE));
148 148
 				}
149 149
 			} elseif ($letter === 'T') {
150 150
 				if (strlen($elem) == 1) {
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 					preg_match_all('/(\d+)([HMS])/', $elem, $match);
154 154
 
155 155
 					if (count($match[1]) !== count(array_unique($match[2]))) {
156
-						throw new Exception('Duplicate definitions in OCRA suite data input timestamp: ' . var_export($elem, TRUE));
156
+						throw new Exception('Duplicate definitions in OCRA suite data input timestamp: '.var_export($elem, TRUE));
157 157
 					}
158 158
 
159 159
 					$length = 0;
@@ -161,21 +161,21 @@  discard block
 block discarded – undo
161 161
 						$length += intval($match[1][$i]) * $this->TPeriods[$match[2][$i]];
162 162
 					}
163 163
 					if ($length <= 0) {
164
-						throw new Exception('Invalid OCRA suite data input timestamp: ' . var_export($elem, TRUE));
164
+						throw new Exception('Invalid OCRA suite data input timestamp: '.var_export($elem, TRUE));
165 165
 					}
166 166
 
167 167
 					$this->T = TRUE;
168 168
 					$this->TLength = $length;
169 169
 				} else {
170
-					throw new Exception('Invalid OCRA suite data input timestamp: ' . var_export($elem, TRUE));
170
+					throw new Exception('Invalid OCRA suite data input timestamp: '.var_export($elem, TRUE));
171 171
 				}
172 172
 			} else {
173
-				throw new Exception('Unsupported OCRA suite data input field: ' . var_export($elem, TRUE));
173
+				throw new Exception('Unsupported OCRA suite data input field: '.var_export($elem, TRUE));
174 174
 			}
175 175
 		}
176 176
 
177 177
 		if (!$this->Q) {
178
-			throw new Exception('OCRA suite data input question not defined: ' . var_export($s[2], TRUE));
178
+			throw new Exception('OCRA suite data input question not defined: '.var_export($s[2], TRUE));
179 179
 		}
180 180
 	}
181 181
 
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 
197 197
         $bytes = Tiqr_Random::randomBytes($q_length);
198 198
 
199
-		switch($q_type) {
199
+		switch ($q_type) {
200 200
 			case 'A':
201 201
 				$challenge = base64_encode($bytes);
202 202
 				$tr = implode("", unpack('H*', $bytes));
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 				$challenge = implode("", unpack('N*', $bytes));
210 210
 				break;
211 211
 			default:
212
-				throw new Exception('Unsupported OCRASuite challenge type: ' . var_export($q_type, TRUE));
212
+				throw new Exception('Unsupported OCRASuite challenge type: '.var_export($q_type, TRUE));
213 213
 				break;
214 214
 		}
215 215
 
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 			$result &= ($s1[$i] == $s2[$i]);
234 234
 		}
235 235
 
236
-		return (boolean)$result;
236
+		return (boolean) $result;
237 237
 	}
238 238
 
239 239
 }
Please login to merge, or discard this patch.
library/tiqr/Tiqr/OcraService/Abstract.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
35 35
         $this->logger = $logger;
36 36
 
37 37
         // Set the OCRA suite
38
-        $this->_ocraSuite = $config['ocra.suite'] ?? 'OCRA-1:HOTP-SHA1-6:QH10-S';   // Use tiqr server default suite
38
+        $this->_ocraSuite = $config['ocra.suite'] ?? 'OCRA-1:HOTP-SHA1-6:QH10-S'; // Use tiqr server default suite
39 39
         $this->_ocraParser = new OATH_OCRAParser($this->_ocraSuite);
40 40
     }
41 41
 
Please login to merge, or discard this patch.
library/tiqr/Tiqr/Service.php 1 patch
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
     // INVALID_USERID: The client authenticated a different user than the server expected. This error is returned when
110 110
     // the application stated an authentication session specifying the userId and later during the authentication
111 111
     // provides a different userId
112
-    const AUTH_RESULT_INVALID_USERID    = 5;
112
+    const AUTH_RESULT_INVALID_USERID = 5;
113 113
     
114 114
     /**
115 115
      * 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;
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
                 case 'APNS':
348 348
                 case 'APNS_DIRECT':
349 349
                     $apns_version = $this->_options['apns.version'] ?? 2;
350
-                    if ($apns_version !=2)
350
+                    if ($apns_version != 2)
351 351
                         throw new InvalidArgumentException("Unsupported APNS version '$apns_version'");
352 352
                     $message = new Tiqr_Message_APNS2($this->_options, $this->logger);
353 353
                     break;
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
 
365 365
             $this->logger->info(sprintf('Creating and sending a %s push notification', $notificationType));
366 366
             $message->setId(time());
367
-            $message->setText("Please authenticate for " . $this->_name);
367
+            $message->setText("Please authenticate for ".$this->_name);
368 368
             $message->setAddress($notificationAddress);
369 369
             $message->setCustomProperty('challenge', $this->_getChallengeUrl($sessionKey));
370 370
             $message->send();
@@ -410,13 +410,13 @@  discard block
 block discarded – undo
410 410
      * @return string The authentication sessionKey
411 411
      * @throws Exception when starting the authentication session failed
412 412
      */
413
-    public function startAuthenticationSession(string $userId="", string $sessionId="", string $spIdentifier=""): string
413
+    public function startAuthenticationSession(string $userId = "", string $sessionId = "", string $spIdentifier = ""): string
414 414
     {
415
-        if ($sessionId=="") {
415
+        if ($sessionId == "") {
416 416
             $sessionId = session_id();
417 417
         }
418 418
 
419
-        if ($spIdentifier=="") {
419
+        if ($spIdentifier == "") {
420 420
             $spIdentifier = $this->_identifier;
421 421
         }
422 422
 
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
         
426 426
         $data = array("sessionId"=>$sessionId, "challenge"=>$challenge, "spIdentifier" => $spIdentifier);
427 427
         
428
-        if ($userId!="") {
428
+        if ($userId != "") {
429 429
             $data["userId"] = $userId;
430 430
         }
431 431
         
@@ -449,9 +449,9 @@  discard block
 block discarded – undo
449 449
      * @return String The enrollment key
450 450
      * @throws Exception when start the enrollement session failed
451 451
      */
452
-    public function startEnrollmentSession(string $userId, string $displayName, string $sessionId=""): string
452
+    public function startEnrollmentSession(string $userId, string $displayName, string $sessionId = ""): string
453 453
     {
454
-        if ($sessionId=="") {
454
+        if ($sessionId == "") {
455 455
             $sessionId = session_id();
456 456
         }
457 457
         $enrollmentKey = $this->_uniqueSessionKey();
@@ -471,9 +471,9 @@  discard block
 block discarded – undo
471 471
      * @param string $sessionId The application's session identifier (defaults to php session)
472 472
      * @throws Exception when resetting the session failed
473 473
      */
474
-    public function resetEnrollmentSession(string $sessionId=""): void
474
+    public function resetEnrollmentSession(string $sessionId = ""): void
475 475
     {
476
-        if ($sessionId=="") {
476
+        if ($sessionId == "") {
477 477
             $sessionId = session_id();
478 478
         }
479 479
 
@@ -508,9 +508,9 @@  discard block
 block discarded – undo
508 508
      *
509 509
      * @throws Exception when an error communicating with the state storage backend was detected
510 510
      */
511
-    public function getEnrollmentStatus(string $sessionId=""): int
511
+    public function getEnrollmentStatus(string $sessionId = ""): int
512 512
     { 
513
-        if ($sessionId=="") {
513
+        if ($sessionId == "") {
514 514
             $sessionId = session_id(); 
515 515
         }
516 516
         $status = $this->_getStateValue(self::PREFIX_ENROLLMENT_STATUS, $sessionId);
@@ -663,7 +663,7 @@  discard block
 block discarded – undo
663 663
             if (NULL === $data) {
664 664
                 throw new RuntimeException('Enrollment secret not found');
665 665
             }
666
-            if ( !is_array($data) || !is_string($data["userId"] ?? NULL)) {
666
+            if (!is_array($data) || !is_string($data["userId"] ?? NULL)) {
667 667
                 throw new RuntimeException('Invalid enrollment data');
668 668
             }
669 669
 
@@ -703,7 +703,7 @@  discard block
 block discarded – undo
703 703
                 $this->_setEnrollmentStatus($data["sessionId"], self::ENROLLMENT_STATUS_FINALIZED);
704 704
             } else {
705 705
                 $this->logger->error(
706
-                    'Enrollment status is not finalized, enrollmentsecret was not found in state storage. ' .
706
+                    'Enrollment status is not finalized, enrollmentsecret was not found in state storage. '.
707 707
                     'Warning! the method will still return "true" as a result.'
708 708
                 );
709 709
             }
@@ -761,9 +761,9 @@  discard block
 block discarded – undo
761 761
             throw $e;
762 762
         }
763 763
 
764
-        $sessionId = $state["sessionId"] ?? NULL;   // Application's sessionId
765
-        $challenge = $state["challenge"] ?? NULL;   // The challenge we sent to the Tiqr client
766
-        if (!is_string($sessionId) || (!is_string($challenge)) ) {
764
+        $sessionId = $state["sessionId"] ?? NULL; // Application's sessionId
765
+        $challenge = $state["challenge"] ?? NULL; // The challenge we sent to the Tiqr client
766
+        if (!is_string($sessionId) || (!is_string($challenge))) {
767 767
             throw new RuntimeException('Invalid state for state storage');
768 768
         }
769 769
 
@@ -772,7 +772,7 @@  discard block
 block discarded – undo
772 772
         $challengeUserId = $state["userId"] ?? NULL;
773 773
 
774 774
         // If the application requested a specific userId, verify that that is that userId that we're now authenticating
775
-        if ($challengeUserId!==NULL && ($userId !== $challengeUserId)) {
775
+        if ($challengeUserId !== NULL && ($userId !== $challengeUserId)) {
776 776
             $this->logger->error(
777 777
                 sprintf('Authentication failed: the requested userId "%s" does not match userId "%s" that is being authenticated',
778 778
                 $challengeUserId, $userId)
@@ -820,9 +820,9 @@  discard block
 block discarded – undo
820 820
      *
821 821
      * @throws Exception when there was an error communicating with the storage backed
822 822
      */
823
-    public function logout(string $sessionId=""): void
823
+    public function logout(string $sessionId = ""): void
824 824
     {
825
-        if ($sessionId=="") {
825
+        if ($sessionId == "") {
826 826
             $sessionId = session_id(); 
827 827
         }
828 828
         
@@ -862,9 +862,9 @@  discard block
 block discarded – undo
862 862
      *
863 863
      * Does not throw
864 864
      */
865
-    public function getAuthenticatedUser(string $sessionId=""): ?string
865
+    public function getAuthenticatedUser(string $sessionId = ""): ?string
866 866
     {
867
-        if ($sessionId=="") {
867
+        if ($sessionId == "") {
868 868
             $this->logger->debug('Using the PHP session id, as no session id was provided');
869 869
             $sessionId = session_id(); 
870 870
         }
@@ -908,22 +908,22 @@  discard block
 block discarded – undo
908 908
         $challenge = $state["challenge"] ?? '';
909 909
         $spIdentifier = $state["spIdentifier"] ?? '';
910 910
 
911
-        if ( (strpos($this->_protocolAuth, 'https://') === 0) || (strpos($this->_protocolAuth, 'http://') === 0) ) {
911
+        if ((strpos($this->_protocolAuth, 'https://') === 0) || (strpos($this->_protocolAuth, 'http://') === 0)) {
912 912
             // Create universal Link
913
-            $parameters=array();
913
+            $parameters = array();
914 914
             if (!is_null($userId)) {
915
-                $parameters[]='u='.urlencode($userId);
915
+                $parameters[] = 'u='.urlencode($userId);
916 916
             }
917
-            $parameters[]='s='.urlencode($sessionKey);
918
-            $parameters[]='q='.urlencode($challenge);
919
-            $parameters[]='i='.urlencode($this->getIdentifier());
920
-            $parameters[]='v='.urlencode($this->_protocolVersion);
917
+            $parameters[] = 's='.urlencode($sessionKey);
918
+            $parameters[] = 'q='.urlencode($challenge);
919
+            $parameters[] = 'i='.urlencode($this->getIdentifier());
920
+            $parameters[] = 'v='.urlencode($this->_protocolVersion);
921 921
             return $this->_protocolAuth.'?'.implode('&', $parameters);
922 922
         }
923 923
 
924 924
         // Create custom URL scheme
925 925
         // Last bit is the spIdentifier
926
-        return $this->_protocolAuth."://".(!is_null($userId)?urlencode($userId).'@':'').$this->getIdentifier()."/".$sessionKey."/".$challenge."/".urlencode($spIdentifier)."/".$this->_protocolVersion;
926
+        return $this->_protocolAuth."://".(!is_null($userId) ?urlencode($userId).'@' : '').$this->getIdentifier()."/".$sessionKey."/".$challenge."/".urlencode($spIdentifier)."/".$this->_protocolVersion;
927 927
     }
928 928
 
929 929
     /**
@@ -934,7 +934,7 @@  discard block
 block discarded – undo
934 934
     {
935 935
         // The are two formats see: https://tiqr.org/technical/protocol/
936 936
 
937
-        if ( (strpos($this->_protocolEnroll, 'https://') === 0) || (strpos($this->_protocolEnroll, 'http://') === 0) ) {
937
+        if ((strpos($this->_protocolEnroll, 'https://') === 0) || (strpos($this->_protocolEnroll, 'http://') === 0)) {
938 938
             // Create universal Link
939 939
             return $this->_protocolEnroll.'?metadata='.urlencode($metadataUrl);
940 940
         }
@@ -953,7 +953,7 @@  discard block
 block discarded – undo
953 953
     protected function _uniqueSessionKey(): string
954 954
     {
955 955
 
956
-        return bin2hex( Tiqr_Random::randomBytes(self::SESSION_KEY_LENGTH_BYTES) );
956
+        return bin2hex(Tiqr_Random::randomBytes(self::SESSION_KEY_LENGTH_BYTES));
957 957
     }
958 958
     
959 959
     /**
@@ -984,7 +984,7 @@  discard block
 block discarded – undo
984 984
      */
985 985
     protected function _setStateValue(string $key_prefix, string $key, $value, int $expire): void {
986 986
         $this->_stateStorage->setValue(
987
-            $key_prefix . $this->_hashKey($key),
987
+            $key_prefix.$this->_hashKey($key),
988 988
             $value,
989 989
             $expire
990 990
         );
@@ -1001,7 +1001,7 @@  discard block
 block discarded – undo
1001 1001
 
1002 1002
     protected function _getStateValue(string $key_prefix, string $key) {
1003 1003
         return $this->_stateStorage->getValue(
1004
-            $key_prefix . $this->_hashKey($key)
1004
+            $key_prefix.$this->_hashKey($key)
1005 1005
         );
1006 1006
     }
1007 1007
 
@@ -1015,7 +1015,7 @@  discard block
 block discarded – undo
1015 1015
      */
1016 1016
     protected function _unsetStateValue(string $key_prefix, string $key): void {
1017 1017
         $this->_stateStorage->unsetValue(
1018
-            $key_prefix . $this->_hashKey($key)
1018
+            $key_prefix.$this->_hashKey($key)
1019 1019
         );
1020 1020
     }
1021 1021
 
Please login to merge, or discard this patch.
library/tiqr/Tiqr/DeviceStorage.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -40,10 +40,10 @@
 block discarded – undo
40 40
      * @param LoggerInterface $logger
41 41
      * @throws Exception An exception if an unknown storage is requested.
42 42
      */
43
-    public static function getStorage(string $type="dummy", Array $options=array(), LoggerInterface $logger=null)
43
+    public static function getStorage(string $type = "dummy", Array $options = array(), LoggerInterface $logger = null)
44 44
     {
45 45
         if (!$logger)
46
-            $logger=new \Psr\Log\NullLogger();
46
+            $logger = new \Psr\Log\NullLogger();
47 47
 
48 48
         switch ($type) {
49 49
             case "dummy":
Please login to merge, or discard this patch.
library/tiqr/Tiqr/UserSecretStorage/UserSecretStorageTrait.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -54,13 +54,13 @@  discard block
 block discarded – undo
54 54
         if ($prefix === $this->encryption->get_type()) {
55 55
             // Decrypt the secret if it is prefixed with the current encryption type
56 56
             // Remove the encryption type prefix before decrypting
57
-           return $this->encryption->decrypt( substr($encryptedSecret, $pos+1) );
57
+           return $this->encryption->decrypt(substr($encryptedSecret, $pos + 1));
58 58
         }
59 59
 
60 60
         // Check the decryption array for the encryption type to see if there is an encryption
61 61
         // instance defined for it. If so, use that to decrypt the secret.
62 62
         if (isset($this->decryption[$prefix])) {
63
-            return $this->decryption[$prefix]->decrypt( substr($encryptedSecret, $pos+1) );
63
+            return $this->decryption[$prefix]->decrypt(substr($encryptedSecret, $pos + 1));
64 64
         }
65 65
 
66 66
         $this->logger->error("Secret for user '$userId' is encrypted with unsupported encryption type '$prefix'");
@@ -77,6 +77,6 @@  discard block
 block discarded – undo
77 77
     {
78 78
         $encryptedSecret = $this->encryption->encrypt($secret);
79 79
         // Prefix the user secret with the encryption type
80
-        $this->setUserSecret($userId, $this->encryption->get_type() . ':' . $encryptedSecret);
80
+        $this->setUserSecret($userId, $this->encryption->get_type().':'.$encryptedSecret);
81 81
     }
82 82
 }
Please login to merge, or discard this patch.
library/tiqr/Tiqr/UserSecretStorage/Encryption.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@
 block discarded – undo
38 38
      *
39 39
      * @return Tiqr_UserSecretStorage_Encryption_Interface
40 40
      */
41
-    public static function getEncryption(LoggerInterface $logger, string $type="dummy", array $options=array()): Tiqr_UserSecretStorage_Encryption_Interface
41
+    public static function getEncryption(LoggerInterface $logger, string $type = "dummy", array $options = array()): Tiqr_UserSecretStorage_Encryption_Interface
42 42
     {
43 43
         $instance = null;
44 44
         $logger->info(sprintf('Using "%s" as UserSecretStorage encryption type', $type));
Please login to merge, or discard this patch.