Passed
Push — develop ( 6fb9ed...4c8ea7 )
by Pieter van der
01:18 queued 14s
created
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($type="file", $options=array(), LoggerInterface $logger)
44
+    public static function getStorage($type = "file", $options = array(), LoggerInterface $logger)
45 45
     {
46 46
         switch ($type) {
47 47
             case "file":
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($type="tiqr", $options=array(), LoggerInterface $logger)
42
+    public static function getOcraService($type = "tiqr", $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/StateStorage.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 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($type="file", $options=array(), LoggerInterface $logger)
50
+    public static function getStorage($type = "file", $options = array(), LoggerInterface $logger)
51 51
     {
52 52
         switch ($type) {
53 53
             case "file":
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
                     }
76 76
                 }
77 77
 
78
-                $pdoInstance = new PDO($options['dsn'],$options['username'],$options['password']);
78
+                $pdoInstance = new PDO($options['dsn'], $options['username'], $options['password']);
79 79
                 // Set a hard-coded default for the probability the expired state is removed
80 80
                 // 0.1 translates to a 10% chance the garbage collection is executed
81 81
                 $cleanupProbability = 0.1;
Please login to merge, or discard this patch.
library/tiqr/Tiqr/StateStorage/File.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -51,8 +51,8 @@
 block discarded – undo
51 51
     public function setValue($key, $value, $expire=0)
52 52
     {   
53 53
         $envelope = array("expire"=>$expire,
54
-                          "createdAt"=>time(),
55
-                          "value"=>$value);
54
+                            "createdAt"=>time(),
55
+                            "value"=>$value);
56 56
         $filename = $this->getFilenameByKey($key);
57 57
         
58 58
         if (!file_put_contents($filename, serialize($envelope))) {
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
         $this->path = $path;
45 45
     }
46 46
 
47
-    public function setValue($key, $value, $expire=0)
47
+    public function setValue($key, $value, $expire = 0)
48 48
     {   
49 49
         $envelope = array("expire"=>$expire,
50 50
                           "createdAt"=>time(),
@@ -98,8 +98,8 @@  discard block
 block discarded – undo
98 98
 
99 99
     private function getPath(): string
100 100
     {
101
-        if (substr($this->path, -1)!=="/") {
102
-            return $this->path . "/";
101
+        if (substr($this->path, -1) !== "/") {
102
+            return $this->path."/";
103 103
         }
104 104
         return $this->path;
105 105
     }
Please login to merge, or discard this patch.
library/tiqr/Tiqr/StateStorage/Abstract.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@
 block discarded – undo
60 60
      * a state storage instance of a certain type.
61 61
      * @param array $options An array of options for the state storage
62 62
      */
63
-    public function __construct($options=array(), LoggerInterface $logger)
63
+    public function __construct($options = array(), LoggerInterface $logger)
64 64
     {
65 65
         $this->logger = $logger;
66 66
         $this->_options = $options;
Please login to merge, or discard this patch.
library/tiqr/Tiqr/UserSecretStorage/Pdo.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
     private function getUserSecret($userId)
83 83
     {
84 84
         $sth = $this->handle->prepare("SELECT secret FROM ".$this->tableName." WHERE userid = ?");
85
-        if($sth->execute(array($userId))) {
85
+        if ($sth->execute(array($userId))) {
86 86
             $secret = $sth->fetchColumn();
87 87
             if ($secret !== false) {
88 88
                 return $secret;
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
         } else {
105 105
             $sth = $this->handle->prepare("INSERT INTO ".$this->tableName." (secret,userid) VALUES (?,?)");
106 106
         }
107
-        $result = $sth->execute(array($secret,$userId));
107
+        $result = $sth->execute(array($secret, $userId));
108 108
         if (!$result) {
109 109
             throw new ReadWriteException('Unable to persist user secret in user secret storage (PDO)');
110 110
         }
Please login to merge, or discard this patch.
library/tiqr/Tiqr/UserStorage/Pdo.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
         parent::__construct($config, $logger);
47 47
         $this->tablename = isset($config['table']) ? $config['table'] : 'tiqruser';
48 48
         try {
49
-            $this->handle = new PDO($config['dsn'],$config['username'],$config['password']);
49
+            $this->handle = new PDO($config['dsn'], $config['username'], $config['password']);
50 50
         } catch (PDOException $e) {
51 51
             $this->logger->error(
52 52
                 sprintf('Unable to establish a PDO connection. Error message from PDO: %s', $e->getMessage())
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
         } else {
62 62
             $sth = $this->handle->prepare("INSERT INTO ".$this->tablename." (displayname,userid) VALUES (?,?)");
63 63
         }
64
-        if ($sth->execute(array($displayName,$userId))){
64
+        if ($sth->execute(array($displayName, $userId))) {
65 65
             return $this->userExists($userId);
66 66
         }
67 67
         throw new ReadWriteException('The user could not be saved in the user storage (PDO)');
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
     public function setNotificationType($userId, $type)
107 107
     {
108 108
         $sth = $this->handle->prepare("UPDATE ".$this->tablename." SET notificationtype = ? WHERE userid = ?");
109
-        if (!$sth->execute(array($type,$userId))) {
109
+        if (!$sth->execute(array($type, $userId))) {
110 110
             throw new ReadWriteException('Unable to set the notification type in user storage for a given user (PDO)');
111 111
         }
112 112
     }
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
     public function setNotificationAddress($userId, $address)
124 124
     {
125 125
         $sth = $this->handle->prepare("UPDATE ".$this->tablename." SET notificationaddress = ?  WHERE userid = ?");
126
-        if (!$sth->execute(array($address,$userId))) {
126
+        if (!$sth->execute(array($address, $userId))) {
127 127
             throw new ReadWriteException('Unable to set the notification address in user storage for a given user (PDO)');
128 128
 
129 129
         }
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
     public function setLoginAttempts($userId, $amount)
142 142
     {
143 143
         $sth = $this->handle->prepare("UPDATE ".$this->tablename." SET loginattempts = ? WHERE userid = ?");
144
-        if (!$sth->execute(array($amount,$userId))) {
144
+        if (!$sth->execute(array($amount, $userId))) {
145 145
             throw new ReadWriteException('Unable to set login attempts in user storage for a given user (PDO)');
146 146
         }
147 147
     }
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
     
175 175
     public function setTemporaryBlockAttempts($userId, $amount) {
176 176
         $sth = $this->handle->prepare("UPDATE ".$this->tablename." SET tmpblockattempts = ? WHERE userid = ?");
177
-        if (!$sth->execute(array($amount,$userId))) {
177
+        if (!$sth->execute(array($amount, $userId))) {
178 178
             throw new ReadWriteException('Unable to set temp login attempts in user storage for a given user (PDO)');
179 179
         }
180 180
     }
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
     public function setTemporaryBlockTimestamp($userId, $timestamp)
200 200
     {
201 201
         $sth = $this->handle->prepare("UPDATE ".$this->tablename." SET tmpblocktimestamp = ? WHERE userid = ?");
202
-        if (!$sth->execute(array($timestamp,$userId))) {
202
+        if (!$sth->execute(array($timestamp, $userId))) {
203 203
             throw new ReadWriteException('Unable to update temp lock timestamp in user storage for a given user (PDO)');
204 204
         }
205 205
     }
Please login to merge, or discard this patch.
library/tiqr/Tiqr/StateStorage/StateStorageInterface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
      * @param int $expire The expiration (in seconds) of the data
25 25
      * @throws ReadWriteException
26 26
      */
27
-    public function setValue($key, $value, $expire=0);
27
+    public function setValue($key, $value, $expire = 0);
28 28
 
29 29
     /**
30 30
      * Remove a value from the state storage
Please login to merge, or discard this patch.
library/tiqr/Tiqr/StateStorage/Pdo.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
     private function cleanExpired() {
75 75
         $sth = $this->handle->prepare("DELETE FROM ".$this->tablename." WHERE `expire` < ? AND NOT `expire` = 0");
76 76
         $result = $sth->execute(array(time()));
77
-        if (!$result || $sth->rowCount() === 0){
77
+        if (!$result || $sth->rowCount() === 0) {
78 78
             // No exception is thrown here. The application can continue with expired state for now.
79 79
             $this->logger->error('Unable to remove expired keys from the pdo state storage');
80 80
         }
@@ -84,9 +84,9 @@  discard block
 block discarded – undo
84 84
      * (non-PHPdoc)
85 85
      * @see library/tiqr/Tiqr/StateStorage/Tiqr_StateStorage_Abstract::setValue()
86 86
      */
87
-    public function setValue($key, $value, $expire=0)
87
+    public function setValue($key, $value, $expire = 0)
88 88
     {
89
-        if (((float) rand() /(float) getrandmax()) < $this->cleanupProbability) {
89
+        if (((float) rand() / (float) getrandmax()) < $this->cleanupProbability) {
90 90
             $this->cleanExpired();
91 91
         }
92 92
         if ($this->keyExists($key)) {
@@ -96,9 +96,9 @@  discard block
 block discarded – undo
96 96
         }
97 97
         // $expire == 0 means never expire
98 98
         if ($expire != 0) {
99
-            $expire+=time();    // Store unix timestamp after which the expires
99
+            $expire += time(); // Store unix timestamp after which the expires
100 100
         }
101
-        if (!$sth->execute(array(serialize($value),$expire,$key))) {
101
+        if (!$sth->execute(array(serialize($value), $expire, $key))) {
102 102
             throw new ReadWriteException(sprintf('Unable to store "%s" state to the PDO', $key));
103 103
         }
104 104
     }
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
     public function unsetValue($key)
111 111
     {
112 112
         if ($this->keyExists($key)) {
113
-            $sth = $this->handle->prepare("DELETE FROM " . $this->tablename . " WHERE `key` = ?");
113
+            $sth = $this->handle->prepare("DELETE FROM ".$this->tablename." WHERE `key` = ?");
114 114
             $result = $sth->execute(array($key));
115 115
             if (!$result || $sth->rowCount() === 0) {
116 116
                 throw new ReadWriteException(
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
                 $this->logger->error('Unable to prepare the get key statement');
138 138
                 return NULL;
139 139
             }
140
-            if (false === $sth->execute(array($key, time())) ) {
140
+            if (false === $sth->execute(array($key, time()))) {
141 141
                 $this->logger->error('Unable to get key from the pdo state storage');
142 142
                 return NULL;
143 143
             }
Please login to merge, or discard this patch.