| @@ -25,7 +25,7 @@ discard block | ||
| 25 | 25 | */ | 
| 26 | 26 | public function setBaseURL($apiBaseURL) | 
| 27 | 27 |      { | 
| 28 | - $this->_apiBaseURL = rtrim($apiBaseURL, '/') . '/'; | |
| 28 | + $this->_apiBaseURL = rtrim($apiBaseURL, '/').'/'; | |
| 29 | 29 | } | 
| 30 | 30 | |
| 31 | 31 | /** | 
| @@ -78,7 +78,7 @@ discard block | ||
| 78 | 78 | protected function callAPI($resource, $method = "GET", $data = array(), $headers = array()) | 
| 79 | 79 |      { | 
| 80 | 80 | $ch = curl_init(); | 
| 81 | - curl_setopt($ch, CURLOPT_URL, $this->_apiBaseURL . ltrim($resource, '/')); | |
| 81 | + curl_setopt($ch, CURLOPT_URL, $this->_apiBaseURL.ltrim($resource, '/')); | |
| 82 | 82 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | 
| 83 | 83 | |
| 84 | 84 | // Explicitly empty null values, because http_build_query will throw away | 
| @@ -107,7 +107,7 @@ discard block | ||
| 107 | 107 | |
| 108 | 108 | $headerArray = array(); | 
| 109 | 109 |          foreach ($headers as $key => $value) { | 
| 110 | - $headerArray[] = $key . ': ' . $value; | |
| 110 | + $headerArray[] = $key.': '.$value; | |
| 111 | 111 | } | 
| 112 | 112 | |
| 113 | 113 | curl_setopt($ch, CURLOPT_HTTPHEADER, $headerArray); | 
| @@ -35,7 +35,7 @@ | ||
| 35 | 35 | * @param boolean $temporary temporary failure? | 
| 36 | 36 | * @param Exception $parent parent exception | 
| 37 | 37 | */ | 
| 38 | - public function __construct($message, $temporary=false, Exception $parent=null) | |
| 38 | + public function __construct($message, $temporary = false, Exception $parent = null) | |
| 39 | 39 |      { | 
| 40 | 40 | parent::__construct($message, $parent); | 
| 41 | 41 | $this->_temporary = $temporary; | 
| @@ -29,7 +29,7 @@ | ||
| 29 | 29 | * @param string $message exception message | 
| 30 | 30 | * @param Exception $parent parent exception | 
| 31 | 31 | */ | 
| 32 | - public function __construct($message, $parent=null) | |
| 32 | + public function __construct($message, $parent = null) | |
| 33 | 33 |       { | 
| 34 | 34 | parent::__construct($message, 0, $parent); | 
| 35 | 35 | } | 
| @@ -35,7 +35,7 @@ | ||
| 35 | 35 | * @param boolean $temporary temporary failure? | 
| 36 | 36 | * @param Exception $parent parent exception | 
| 37 | 37 | */ | 
| 38 | - public function __construct($message, $temporary=false, Exception $parent=null) | |
| 38 | + public function __construct($message, $temporary = false, Exception $parent = null) | |
| 39 | 39 |      { | 
| 40 | 40 | parent::__construct($message, $parent); | 
| 41 | 41 | $this->_temporary = $temporary; | 
| @@ -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) | 
| @@ -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 | } | 
| @@ -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. |