Passed
Push — master ( 35fb8a...2dccb2 )
by Pieter van der
05:32 queued 14s
created
library/tiqr/Tiqr/StateStorage/Pdo.php 3 patches
Indentation   -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,6 @@
 block discarded – undo
21 21
  * 
22 22
  * 
23 23
  * Create SQL table (MySQL):
24
-
25 24
  * CREATE TABLE IF NOT EXISTS tiqrstate (
26 25
     key varchar(255) PRIMARY KEY,
27 26
     expire BIGINT,
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
             throw new InvalidArgumentException('Empty key not allowed');
78 78
         }
79 79
         try {
80
-            $sth = $this->handle->prepare('SELECT `key` FROM ' . $this->tablename . ' WHERE `key` = ?');
80
+            $sth = $this->handle->prepare('SELECT `key` FROM '.$this->tablename.' WHERE `key` = ?');
81 81
             $sth->execute(array($key));
82 82
             return $sth->fetchColumn() !== false;
83 83
         }
@@ -97,9 +97,9 @@  discard block
 block discarded – undo
97 97
      */
98 98
     private function cleanExpired(): void {
99 99
         try {
100
-            $sth = $this->handle->prepare("DELETE FROM " . $this->tablename . " WHERE `expire` < ? AND NOT `expire` = 0");
100
+            $sth = $this->handle->prepare("DELETE FROM ".$this->tablename." WHERE `expire` < ? AND NOT `expire` = 0");
101 101
             $sth->execute(array(time()));
102
-            $deletedRows=$sth->rowCount();
102
+            $deletedRows = $sth->rowCount();
103 103
             $this->logger->notice(
104 104
                 sprintf("Deleted %i expired keys", $deletedRows)
105 105
             );
@@ -115,12 +115,12 @@  discard block
 block discarded – undo
115 115
     /**
116 116
      * @see Tiqr_StateStorage_StateStorageInterface::setValue()
117 117
      */
118
-    public function setValue(string $key, $value, int $expire=0): void
118
+    public function setValue(string $key, $value, int $expire = 0): void
119 119
     {
120 120
         if (empty($key)) {
121 121
             throw new InvalidArgumentException('Empty key not allowed');
122 122
         }
123
-        if (((float) rand() /(float) getrandmax()) < $this->cleanupProbability) {
123
+        if (((float) rand() / (float) getrandmax()) < $this->cleanupProbability) {
124 124
             $this->cleanExpired();
125 125
         }
126 126
         if ($this->keyExists($key)) {
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
         }
131 131
         // $expire == 0 means never expire
132 132
         if ($expire != 0) {
133
-            $expire+=time();    // Store unix timestamp after which the expires
133
+            $expire += time(); // Store unix timestamp after which the expires
134 134
         }
135 135
         try {
136 136
             $sth->execute(array(serialize($value), $expire, $key));
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
             throw new InvalidArgumentException('Empty key not allowed');
154 154
         }
155 155
         try {
156
-            $sth = $this->handle->prepare("DELETE FROM " . $this->tablename . " WHERE `key` = ?");
156
+            $sth = $this->handle->prepare("DELETE FROM ".$this->tablename." WHERE `key` = ?");
157 157
             $sth->execute(array($key));
158 158
         }
159 159
         catch (Exception $e) {
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
         }
184 184
 
185 185
         try {
186
-            $sth = $this->handle->prepare('SELECT `value` FROM ' . $this->tablename . ' WHERE `key` = ? AND (`expire` >= ? OR `expire` = 0)');
186
+            $sth = $this->handle->prepare('SELECT `value` FROM '.$this->tablename.' WHERE `key` = ? AND (`expire` >= ? OR `expire` = 0)');
187 187
             $sth->execute(array($key, time()));
188 188
         }
189 189
         catch (Exception $e) {
@@ -197,9 +197,9 @@  discard block
 block discarded – undo
197 197
         if (false === $result) {
198 198
             // Occurs normally
199 199
             $this->logger->info(sprintf('getValue: Key "%s" not found in PDO StateStorage', $key));
200
-            return NULL;    // Key not found
200
+            return NULL; // Key not found
201 201
         }
202
-        $result=unserialize($result, array('allowed_classes' => false));
202
+        $result = unserialize($result, array('allowed_classes' => false));
203 203
         if (false === $result) {
204 204
             throw new RuntimeException(sprintf('getValue: unserialize error for key "%s" in PDO StateStorage', $key));
205 205
         }
Please login to merge, or discard this patch.
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -80,8 +80,7 @@  discard block
 block discarded – undo
80 80
             $sth = $this->handle->prepare('SELECT `key` FROM ' . $this->tablename . ' WHERE `key` = ?');
81 81
             $sth->execute(array($key));
82 82
             return $sth->fetchColumn() !== false;
83
-        }
84
-        catch (Exception $e) {
83
+        } catch (Exception $e) {
85 84
             $this->logger->error(
86 85
                 sprintf('Error checking for key "%s" in PDO StateStorage', $key),
87 86
                 array('exception' => $e)
@@ -103,8 +102,7 @@  discard block
 block discarded – undo
103 102
             $this->logger->notice(
104 103
                 sprintf("Deleted %i expired keys", $deletedRows)
105 104
             );
106
-        }
107
-        catch (Exception $e) {
105
+        } catch (Exception $e) {
108 106
             $this->logger->error(
109 107
                 sprintf("Deleting expired keys failed: %s", $e->getMessage()),
110 108
                 array('exception', $e)
@@ -134,8 +132,7 @@  discard block
 block discarded – undo
134 132
         }
135 133
         try {
136 134
             $sth->execute(array(serialize($value), $expire, $key));
137
-        }
138
-        catch (Exception $e) {
135
+        } catch (Exception $e) {
139 136
             $this->logger->error(
140 137
                 sprintf('Unable to store key "%s" in PDO StateStorage', $key),
141 138
                 array('exception' => $e)
@@ -155,8 +152,7 @@  discard block
 block discarded – undo
155 152
         try {
156 153
             $sth = $this->handle->prepare("DELETE FROM " . $this->tablename . " WHERE `key` = ?");
157 154
             $sth->execute(array($key));
158
-        }
159
-        catch (Exception $e) {
155
+        } catch (Exception $e) {
160 156
             $this->logger->error(
161 157
                 sprintf('Error deleting key "%s" from PDO StateStorage', $key),
162 158
                 array('exception' => $e)
@@ -185,8 +181,7 @@  discard block
 block discarded – undo
185 181
         try {
186 182
             $sth = $this->handle->prepare('SELECT `value` FROM ' . $this->tablename . ' WHERE `key` = ? AND (`expire` >= ? OR `expire` = 0)');
187 183
             $sth->execute(array($key, time()));
188
-        }
189
-        catch (Exception $e) {
184
+        } catch (Exception $e) {
190 185
             $this->logger->error(
191 186
                 sprintf('Error getting value for key "%s" from PDO StateStorage', $key),
192 187
                 array('exception' => $e)
Please login to merge, or discard this patch.
library/tiqr/Tiqr/OcraService.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@
 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)
42
+    public static function getOcraService(string $type = "tiqr", array $options = array(), LoggerInterface $logger)
43 43
     {
44 44
         switch ($type) {
45 45
             case "tiqr":
Please login to merge, or discard this patch.
library/tiqr/Tiqr/UserStorage.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@
 block discarded – undo
41 41
      *
42 42
      * @throws Exception An exception if an unknown user storage is requested.
43 43
      */
44
-    public static function getStorage(string $type="file", array $options=array(), LoggerInterface $logger): Tiqr_UserStorage_Interface
44
+    public static function getStorage(string $type = "file", array $options = array(), LoggerInterface $logger): Tiqr_UserStorage_Interface
45 45
     {
46 46
         switch ($type) {
47 47
             case "file":
Please login to merge, or discard this patch.
library/tiqr/Tiqr/OcraService/Tiqr.php 2 patches
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.
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/OcraService/OathServiceClient.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -81,7 +81,7 @@
 block discarded – undo
81 81
                     'verifyResponse for user "%s" failed',
82 82
                     $userId
83 83
                 ),
84
-                array( 'exception' => $e)
84
+                array('exception' => $e)
85 85
             );
86 86
             return false;
87 87
         }
Please login to merge, or discard this patch.
library/tiqr/Tiqr/OcraService/Abstract.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 
20 20
 use Psr\Log\LoggerInterface;
21 21
 
22
-require_once(__DIR__ . '/../OATH/OCRAParser.php');
22
+require_once(__DIR__.'/../OATH/OCRAParser.php');
23 23
 
24 24
 abstract class Tiqr_OcraService_Abstract implements Tiqr_OcraService_Interface
25 25
 {
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
         $this->logger = $logger;
38 38
 
39 39
         // Set the OCRA suite
40
-        $this->_ocraSuite = $config['ocra.suite'] ?? 'OCRA-1:HOTP-SHA1-6:QH10-S';   // Use tiqr server default suite
40
+        $this->_ocraSuite = $config['ocra.suite'] ?? 'OCRA-1:HOTP-SHA1-6:QH10-S'; // Use tiqr server default suite
41 41
         $this->_ocraParser = new OATH_OCRAParser($this->_ocraSuite);
42 42
     }
43 43
 
Please login to merge, or discard this patch.
library/tiqr/Tiqr/Random.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@
 block discarded – undo
42 42
     public static function randomBytes(int $length): string
43 43
     {
44 44
         // Get $length cryptographically secure pseudo-random bytes
45
-        $rnd=\random_bytes($length);
45
+        $rnd = \random_bytes($length);
46 46
 
47 47
         if (strlen($rnd) !== $length) {
48 48
             throw new Exception("random_bytes did not return the requested number of bytes");
Please login to merge, or discard this patch.
library/tiqr/Tiqr/StateStorage.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@
 block discarded – undo
47 47
      * @throws RuntimeException When the options configuration array misses a required parameter
48 48
      *
49 49
      */
50
-    public static function getStorage(string $type="file", array $options=array(), LoggerInterface $logger)
50
+    public static function getStorage(string $type = "file", array $options = array(), LoggerInterface $logger)
51 51
     {
52 52
         switch ($type) {
53 53
             case "file":
Please login to merge, or discard this patch.
library/tiqr/Tiqr/Exception/ReadWriteException.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,6 +22,6 @@
 block discarded – undo
22 22
     {
23 23
         // $code must be int, otherwise this throws with Error("Wrong parameters for ReadWriteException")
24 24
         // PDOException::getCode() can return a sting
25
-        return new self($e->getMessage(), (int)$e->getCode(), $e );
25
+        return new self($e->getMessage(), (int) $e->getCode(), $e);
26 26
     }
27 27
 }
Please login to merge, or discard this patch.