@@ -79,7 +79,7 @@ |
||
79 | 79 | */ |
80 | 80 | private function setUserSecret(string $userId, string $secret): void |
81 | 81 | { |
82 | - $data=array(); |
|
82 | + $data = array(); |
|
83 | 83 | if ($this->_userExists($userId)) { |
84 | 84 | $data = $this->_loadUser($userId); |
85 | 85 | } |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | public function userExists(string $userId): bool |
84 | 84 | { |
85 | 85 | try { |
86 | - $sth = $this->handle->prepare('SELECT userid FROM ' . $this->tableName . ' WHERE userid = ?'); |
|
86 | + $sth = $this->handle->prepare('SELECT userid FROM '.$this->tableName.' WHERE userid = ?'); |
|
87 | 87 | $sth->execute(array($userId)); |
88 | 88 | return (false !== $sth->fetchColumn()); |
89 | 89 | } |
@@ -103,9 +103,9 @@ discard block |
||
103 | 103 | private function getUserSecret(string $userId): string |
104 | 104 | { |
105 | 105 | try { |
106 | - $sth = $this->handle->prepare('SELECT secret FROM ' . $this->tableName . ' WHERE userid = ?'); |
|
106 | + $sth = $this->handle->prepare('SELECT secret FROM '.$this->tableName.' WHERE userid = ?'); |
|
107 | 107 | $sth->execute(array($userId)); |
108 | - $res=$sth->fetchColumn(); |
|
108 | + $res = $sth->fetchColumn(); |
|
109 | 109 | if ($res === false) { |
110 | 110 | // No result |
111 | 111 | $this->logger->error(sprintf('No result getting secret for user "%s"', $userId)); |
@@ -141,9 +141,9 @@ discard block |
||
141 | 141 | // - The INSERT will fail when displayname has a NOT NULL constraint |
142 | 142 | try { |
143 | 143 | if ($this->userExists($userId)) { |
144 | - $sth = $this->handle->prepare('UPDATE ' . $this->tableName . ' SET secret = ? WHERE userid = ?'); |
|
144 | + $sth = $this->handle->prepare('UPDATE '.$this->tableName.' SET secret = ? WHERE userid = ?'); |
|
145 | 145 | } else { |
146 | - $sth = $this->handle->prepare('INSERT INTO ' . $this->tableName . ' (secret,userid) VALUES (?,?)'); |
|
146 | + $sth = $this->handle->prepare('INSERT INTO '.$this->tableName.' (secret,userid) VALUES (?,?)'); |
|
147 | 147 | } |
148 | 148 | $sth->execute(array($secret, $userId)); |
149 | 149 | } |
@@ -86,8 +86,7 @@ discard block |
||
86 | 86 | $sth = $this->handle->prepare('SELECT userid FROM ' . $this->tableName . ' WHERE userid = ?'); |
87 | 87 | $sth->execute(array($userId)); |
88 | 88 | return (false !== $sth->fetchColumn()); |
89 | - } |
|
90 | - catch (Exception $e) { |
|
89 | + } catch (Exception $e) { |
|
91 | 90 | $this->logger->error('PDO error checking user exists', array('exception'=>$e, 'userId'=>$userId)); |
92 | 91 | throw ReadWriteException::fromOriginalException($e); |
93 | 92 | } |
@@ -111,8 +110,7 @@ discard block |
||
111 | 110 | $this->logger->error(sprintf('No result getting secret for user "%s"', $userId)); |
112 | 111 | throw new RuntimeException('User not found'); |
113 | 112 | } |
114 | - } |
|
115 | - catch (Exception $e) { |
|
113 | + } catch (Exception $e) { |
|
116 | 114 | $this->logger->error('PDO error getting user', array('exception' => $e, 'userId' => $userId)); |
117 | 115 | throw ReadWriteException::fromOriginalException($e); |
118 | 116 | } |
@@ -146,8 +144,7 @@ discard block |
||
146 | 144 | $sth = $this->handle->prepare('INSERT INTO ' . $this->tableName . ' (secret,userid) VALUES (?,?)'); |
147 | 145 | } |
148 | 146 | $sth->execute(array($secret, $userId)); |
149 | - } |
|
150 | - catch (Exception $e) { |
|
147 | + } catch (Exception $e) { |
|
151 | 148 | $this->logger->error( |
152 | 149 | sprintf('Unable to persist user secret for user "%s" in user secret storage (PDO)', $userId), |
153 | 150 | array('exception'=>$e) |
@@ -59,7 +59,7 @@ |
||
59 | 59 | * @param array $options The options |
60 | 60 | * @param LoggerInterface $logger |
61 | 61 | */ |
62 | - public function __construct(array $options=array(), LoggerInterface $logger) |
|
62 | + public function __construct(array $options = array(), LoggerInterface $logger) |
|
63 | 63 | { |
64 | 64 | $this->_options = $options; |
65 | 65 | $this->logger = $logger; |
@@ -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 | } |
@@ -40,7 +40,7 @@ |
||
40 | 40 | * |
41 | 41 | * @return Tiqr_UserSecretStorage_Encryption_Interface |
42 | 42 | */ |
43 | - public static function getEncryption(LoggerInterface $logger, string $type="dummy", array $options=array()): Tiqr_UserSecretStorage_Encryption_Interface |
|
43 | + public static function getEncryption(LoggerInterface $logger, string $type = "dummy", array $options = array()): Tiqr_UserSecretStorage_Encryption_Interface |
|
44 | 44 | { |
45 | 45 | $logger->info(sprintf('Using %s as UserStorage encryption type', $type)); |
46 | 46 | switch ($type) { |
@@ -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 | } |