@@ -74,7 +74,7 @@ |
||
| 74 | 74 | */ |
| 75 | 75 | public function getPath(): string |
| 76 | 76 | { |
| 77 | - if (substr($this->path, -1)!="/") return $this->path."/"; |
|
| 77 | + if (substr($this->path, -1) != "/") return $this->path."/"; |
|
| 78 | 78 | return $this->path; |
| 79 | 79 | } |
| 80 | 80 | } |
@@ -74,7 +74,9 @@ |
||
| 74 | 74 | */ |
| 75 | 75 | public function getPath(): string |
| 76 | 76 | { |
| 77 | - if (substr($this->path, -1)!="/") return $this->path."/"; |
|
| 77 | + if (substr($this->path, -1)!="/") { |
|
| 78 | + return $this->path."/"; |
|
| 79 | + } |
|
| 78 | 80 | return $this->path; |
| 79 | 81 | } |
| 80 | 82 | } |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | public function createUser(string $userId, string $displayName) : void |
| 61 | 61 | { |
| 62 | 62 | $user = array("userId"=>$userId, |
| 63 | - "displayName"=>$displayName); |
|
| 63 | + "displayName"=>$displayName); |
|
| 64 | 64 | $this->_saveUser($userId, $user); |
| 65 | 65 | } |
| 66 | 66 | |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | { |
| 91 | 91 | if ($data = $this->_loadUser($userId)) { |
| 92 | 92 | if (isset($data["notificationType"])) { |
| 93 | - return $data["notificationType"]; |
|
| 93 | + return $data["notificationType"]; |
|
| 94 | 94 | } |
| 95 | 95 | } |
| 96 | 96 | return ''; |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | { |
| 114 | 114 | if ($data = $this->_loadUser($userId)) { |
| 115 | 115 | if (isset($data["notificationAddress"])) { |
| 116 | - return $data["notificationAddress"]; |
|
| 116 | + return $data["notificationAddress"]; |
|
| 117 | 117 | } |
| 118 | 118 | } |
| 119 | 119 | $this->logger->info('Unable to find notification address for user'); |
@@ -170,10 +170,10 @@ |
||
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | if ($timestamp + $tempBlockDuration * 60 < time()) { |
| 173 | - return false; // Temp block expired |
|
| 173 | + return false; // Temp block expired |
|
| 174 | 174 | } |
| 175 | 175 | } |
| 176 | - return true; // Blocked by temp block |
|
| 176 | + return true; // Blocked by temp block |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | /** |
@@ -128,7 +128,7 @@ |
||
| 128 | 128 | * |
| 129 | 129 | * Note that the $tempBlockDuration is specified in MINUTES |
| 130 | 130 | */ |
| 131 | - public function isBlocked(string $userId, int $tempBlockDuration=0): bool; |
|
| 131 | + public function isBlocked(string $userId, int $tempBlockDuration = 0): bool; |
|
| 132 | 132 | |
| 133 | 133 | /** |
| 134 | 134 | * Block or unblock the user account. |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | * @throws ReadWriteException |
| 30 | 30 | * @throws Exception |
| 31 | 31 | */ |
| 32 | - public function setValue(string $key, $value, int $expire=0): void; |
|
| 32 | + public function setValue(string $key, $value, int $expire = 0): void; |
|
| 33 | 33 | |
| 34 | 34 | /** |
| 35 | 35 | * Remove $key from the state storage |
@@ -54,8 +54,8 @@ |
||
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | $envelope = array("expire"=>$expire, |
| 57 | - "createdAt"=>time(), |
|
| 58 | - "value"=>$value); |
|
| 57 | + "createdAt"=>time(), |
|
| 58 | + "value"=>$value); |
|
| 59 | 59 | $filename = $this->getFilenameByKey($key); |
| 60 | 60 | |
| 61 | 61 | if (!file_put_contents($filename, serialize($envelope))) { |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | /** |
| 48 | 48 | * @see Tiqr_StateStorage_StateStorageInterface::setValue() |
| 49 | 49 | */ |
| 50 | - public function setValue(string $key, $value, int $expire=0): void |
|
| 50 | + public function setValue(string $key, $value, int $expire = 0): void |
|
| 51 | 51 | { |
| 52 | 52 | if (empty($key)) { |
| 53 | 53 | throw new InvalidArgumentException('Empty key not allowed'); |
@@ -109,8 +109,8 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | private function getPath(): string |
| 111 | 111 | { |
| 112 | - if (substr($this->path, -1)!=="/") { |
|
| 113 | - return $this->path . "/"; |
|
| 112 | + if (substr($this->path, -1) !== "/") { |
|
| 113 | + return $this->path."/"; |
|
| 114 | 114 | } |
| 115 | 115 | return $this->path; |
| 116 | 116 | } |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | * The default configuration |
| 52 | 52 | */ |
| 53 | 53 | const DEFAULT_HOST = '127.0.0.1'; |
| 54 | - const DEFAULT_PORT = 11211; |
|
| 54 | + const DEFAULT_PORT = 11211; |
|
| 55 | 55 | |
| 56 | 56 | /** |
| 57 | 57 | * Get the prefix to use for all keys in memcache. |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | /** |
| 104 | 104 | * @see Tiqr_StateStorage_StateStorageInterface::setValue() |
| 105 | 105 | */ |
| 106 | - public function setValue(string $key, $value, int $expire=0): void |
|
| 106 | + public function setValue(string $key, $value, int $expire = 0): void |
|
| 107 | 107 | { |
| 108 | 108 | if (empty($key)) { |
| 109 | 109 | throw new InvalidArgumentException('Empty key not allowed'); |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | if ($result === false) { |
| 158 | 158 | // Memcache interface does not provide error information, either the key does not exists or |
| 159 | 159 | // there was an error communicating with the memcache |
| 160 | - $this->logger->info( sprintf('Unable to get key "%s" from memcache StateStorage', $key) ); |
|
| 160 | + $this->logger->info(sprintf('Unable to get key "%s" from memcache StateStorage', $key)); |
|
| 161 | 161 | return null; |
| 162 | 162 | } |
| 163 | 163 | return $result; |
@@ -36,8 +36,7 @@ |
||
| 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 | } |
@@ -81,7 +81,7 @@ |
||
| 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 | } |
@@ -42,7 +42,7 @@ |
||
| 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"); |