@@ -39,7 +39,7 @@ |
||
39 | 39 | $hostname = $_SERVER['HTTP_HOST']; |
40 | 40 | |
41 | 41 | return [ |
42 | - 'base' => $http.'://'.$hostname, |
|
42 | + 'base' => $http . '://' . $hostname, |
|
43 | 43 | 'protocol' => $http, |
44 | 44 | 'host' => $hostname, |
45 | 45 | ]; |
@@ -71,7 +71,7 @@ |
||
71 | 71 | $base_uri = $this->guzzle->getConfig()['base_uri']; |
72 | 72 | |
73 | 73 | if (strlen($base_uri) > 0) { |
74 | - $url = $base_uri.'/account/new?forgot=true'; |
|
74 | + $url = $base_uri . '/account/new?forgot=true'; |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | return $url; |
@@ -32,7 +32,7 @@ |
||
32 | 32 | public static function generateInt($min, $max) |
33 | 33 | { |
34 | 34 | if ($min >= $max) { |
35 | - throw new InvalidArgumentException('Invalid constraints - minimum ('.$min.') is above the maximum ('.$max.')'); |
|
35 | + throw new InvalidArgumentException('Invalid constraints - minimum (' . $min . ') is above the maximum (' . $max . ')'); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | if (function_exists('random_int')) { // use secure random numbers when available |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | { |
15 | 15 | public function getAvailabilityForm(ServerRequestInterface $request, ResponseInterface $response, $args) |
16 | 16 | { |
17 | - $this->logger->info("Fetch user availability GET '/user/".$args['id']."/availability'"); |
|
17 | + $this->logger->info("Fetch user availability GET '/user/" . $args['id'] . "/availability'"); |
|
18 | 18 | |
19 | 19 | $u = UserQuery::create()->findPk($args['id']); |
20 | 20 | |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | |
34 | 34 | public function postAvailability(ServerRequestInterface $request, ResponseInterface $response, $args) |
35 | 35 | { |
36 | - $this->logger->info("Update user availability POST '/user/".$args['id']."/availability'"); |
|
36 | + $this->logger->info("Update user availability POST '/user/" . $args['id'] . "/availability'"); |
|
37 | 37 | |
38 | 38 | $u = UserQuery::create() |
39 | 39 | ->findPk($args['id']); |
@@ -62,8 +62,8 @@ discard block |
||
62 | 62 | $a->setAvailable(false); |
63 | 63 | } |
64 | 64 | |
65 | - if (strlen($data['event'.$eventId.'comment']) > 0) { |
|
66 | - $a->setComment($data['event'.$eventId.'comment']); |
|
65 | + if (strlen($data['event' . $eventId . 'comment']) > 0) { |
|
66 | + $a->setComment($data['event' . $eventId . 'comment']); |
|
67 | 67 | } else { |
68 | 68 | $a->setComment(null); |
69 | 69 | } |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | { |
14 | 14 | public function getAssignRolesForm(ServerRequestInterface $request, ResponseInterface $response, $args) |
15 | 15 | { |
16 | - $this->logger->info("Fetch user GET '/user/".$args['id']."/roles'"); |
|
16 | + $this->logger->info("Fetch user GET '/user/" . $args['id'] . "/roles'"); |
|
17 | 17 | $r = RoleQuery::create()->find(); |
18 | 18 | $u = UserQuery::create()->findPK($args['id']); |
19 | 19 | |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | |
27 | 27 | public function postUserAssignRoles(ServerRequestInterface $request, ResponseInterface $response, $args) |
28 | 28 | { |
29 | - $this->logger->info("Create user people POST '/user/".$args['id']."/roles'"); |
|
29 | + $this->logger->info("Create user people POST '/user/" . $args['id'] . "/roles'"); |
|
30 | 30 | |
31 | 31 | $userId = filter_var($args['id'], FILTER_SANITIZE_NUMBER_INT); |
32 | 32 | $existingRoles = RoleQuery::create()->useUserRoleQuery()->filterByUserId($userId)->endUse()->find(); |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | |
77 | 77 | public function getRevokeCalendar(ServerRequestInterface $request, ResponseInterface $response, $args) |
78 | 78 | { |
79 | - $this->logger->info("Fetch settings GET '/user/me/calendar/".$args['id']."/revoke'"); |
|
79 | + $this->logger->info("Fetch settings GET '/user/me/calendar/" . $args['id'] . "/revoke'"); |
|
80 | 80 | |
81 | 81 | $auth = $this->auth; |
82 | 82 | $u = $auth->currentUser(); |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | |
102 | 102 | public function getRenderedCalendar(ServerRequestInterface $request, ResponseInterface $response, $args) |
103 | 103 | { |
104 | - $this->logger->info("Fetch calendar GET '/calendar/".$args['token'].'.'.$args['format']."'"); |
|
104 | + $this->logger->info("Fetch calendar GET '/calendar/" . $args['token'] . '.' . $args['format'] . "'"); |
|
105 | 105 | |
106 | 106 | $c = CalendarTokenQuery::create() |
107 | 107 | ->filterByToken($args['token']) |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | { |
119 | 119 | $getParameters = $request->getQueryParams(); |
120 | 120 | |
121 | - $this->logger->info("Fetch -LEGACY- calendar GET '/calendar.php?user=".$getParameters['user'].'&token='.$getParameters['token'].'&format='.$getParameters['format']."'"); |
|
121 | + $this->logger->info("Fetch -LEGACY- calendar GET '/calendar.php?user=" . $getParameters['user'] . '&token=' . $getParameters['token'] . '&format=' . $getParameters['format'] . "'"); |
|
122 | 122 | |
123 | 123 | $userId = filter_var($getParameters['user'], FILTER_VALIDATE_INT); |
124 | 124 | $token = $getParameters['token']; |
@@ -13,7 +13,7 @@ |
||
13 | 13 | if (filter_var(trim($email), FILTER_VALIDATE_EMAIL)) { |
14 | 14 | $this->email = filter_var(trim($email), FILTER_SANITIZE_EMAIL); |
15 | 15 | } else { |
16 | - throw new InvalidArgumentException('Invalid email address: '.$email); |
|
16 | + throw new InvalidArgumentException('Invalid email address: ' . $email); |
|
17 | 17 | } |
18 | 18 | } |
19 | 19 |
@@ -10,7 +10,7 @@ |
||
10 | 10 | // e.g: $app->add(new \Slim\Csrf\Guard); |
11 | 11 | |
12 | 12 | // 3) add route information to twig |
13 | -$app->add(function (Request $request, Response $response, callable $next) { |
|
13 | +$app->add(function(Request $request, Response $response, callable $next) { |
|
14 | 14 | $route = $request->getAttribute('route'); |
15 | 15 | |
16 | 16 | // return NotFound for non existent route |
@@ -148,6 +148,12 @@ discard block |
||
148 | 148 | return $statement->fetchAll(PDO::FETCH_CLASS, $returnClass); |
149 | 149 | } |
150 | 150 | |
151 | + /** |
|
152 | + * @param string $returnClass |
|
153 | + * @param string $table |
|
154 | + * @param string[] $columns |
|
155 | + * @param string[] $where |
|
156 | + */ |
|
151 | 157 | public function selectSingle($returnClass, $table, $columns, $where = null) |
152 | 158 | { |
153 | 159 | $statement = $this->selectStatement($table, $columns, $where); |
@@ -215,6 +221,8 @@ discard block |
||
215 | 221 | |
216 | 222 | /** |
217 | 223 | * Use with caution: it is often better to archive items to prevent creating null references. |
224 | + * @param string $table |
|
225 | + * @param string[] $where |
|
218 | 226 | */ |
219 | 227 | public function delete($table, $where) |
220 | 228 | { |
@@ -253,6 +261,9 @@ discard block |
||
253 | 261 | return $table; |
254 | 262 | } |
255 | 263 | |
264 | + /** |
|
265 | + * @param string $table |
|
266 | + */ |
|
256 | 267 | private function tableExists($table) |
257 | 268 | { |
258 | 269 | // todo: implement table check |
@@ -272,8 +272,8 @@ |
||
272 | 272 | public function count($table, $column, $where = null) |
273 | 273 | { |
274 | 274 | $columns = [ |
275 | - 'COUNT('.$column.') AS count', |
|
276 | - ]; |
|
275 | + 'COUNT('.$column.') AS count', |
|
276 | + ]; |
|
277 | 277 | $statement = $this->selectStatement($table, $columns, $where); |
278 | 278 | |
279 | 279 | return $statement->fetchObject()->count; |
@@ -180,10 +180,10 @@ discard block |
||
180 | 180 | if ($first) { |
181 | 181 | $first = false; |
182 | 182 | $fields .= $item['field']; |
183 | - $valuesPlaceholder .= ':'.$item['field']; |
|
183 | + $valuesPlaceholder .= ':' . $item['field']; |
|
184 | 184 | } else { |
185 | - $fields .= ', '.$item['field']; |
|
186 | - $valuesPlaceholder .= ', :'.$item['field']; |
|
185 | + $fields .= ', ' . $item['field']; |
|
186 | + $valuesPlaceholder .= ', :' . $item['field']; |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | if ($item['type'] == 's' || $item['type'] == 'string') { |
@@ -201,9 +201,9 @@ discard block |
||
201 | 201 | } |
202 | 202 | } |
203 | 203 | |
204 | - $statement = $this->db_connection->prepare('INSERT INTO '.$table.' ('.$fields.') VALUES ('.$valuesPlaceholder.')'); |
|
204 | + $statement = $this->db_connection->prepare('INSERT INTO ' . $table . ' (' . $fields . ') VALUES (' . $valuesPlaceholder . ')'); |
|
205 | 205 | foreach ($data as $item) { |
206 | - $statement->bindParam(':'.$item['field'], $item['value']); |
|
206 | + $statement->bindParam(':' . $item['field'], $item['value']); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | if ($statement->execute()) { |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | |
249 | 249 | private function addPrefix($table) |
250 | 250 | { |
251 | - $table = $this->db_prefix.$table; |
|
251 | + $table = $this->db_prefix . $table; |
|
252 | 252 | |
253 | 253 | return $table; |
254 | 254 | } |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | public function count($table, $column, $where = null) |
273 | 273 | { |
274 | 274 | $columns = [ |
275 | - 'COUNT('.$column.') AS count', |
|
275 | + 'COUNT(' . $column . ') AS count', |
|
276 | 276 | ]; |
277 | 277 | $statement = $this->selectStatement($table, $columns, $where); |
278 | 278 |