Passed
Push — master ( 7a2e61...a5e203 )
by Tim
02:05
created
www/getconsent.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -72,12 +72,12 @@  discard block
 block discarded – undo
72 72
         $attributeSet = $state['consent:store.attributeSet'];
73 73
 
74 74
         \SimpleSAML\Logger::debug(
75
-            'Consent - saveConsent() : [' . $userId . '|' . $targetedId . '|' . $attributeSet . ']'
75
+            'Consent - saveConsent() : ['.$userId.'|'.$targetedId.'|'.$attributeSet.']'
76 76
         );
77 77
         try {
78 78
             $store->saveConsent($userId, $targetedId, $attributeSet);
79 79
         } catch (\Exception $e) {
80
-            \SimpleSAML\Logger::error('Consent: Error writing to storage: ' . $e->getMessage());
80
+            \SimpleSAML\Logger::error('Consent: Error writing to storage: '.$e->getMessage());
81 81
         }
82 82
     }
83 83
 
@@ -228,38 +228,38 @@  discard block
 block discarded – undo
228 228
 
229 229
     $alternate = ['odd', 'even'];
230 230
     $i = 0;
231
-    $summary = 'summary="' . $translator->t('{consent:consent:table_summary}') . '"';
231
+    $summary = 'summary="'.$translator->t('{consent:consent:table_summary}').'"';
232 232
 
233 233
     if (strlen($nameParent) > 0) {
234
-        $parentStr = strtolower($nameParent) . '_';
235
-        $str = '<table class="attributes" ' . $summary . '>';
234
+        $parentStr = strtolower($nameParent).'_';
235
+        $str = '<table class="attributes" '.$summary.'>';
236 236
     } else {
237 237
         $parentStr = '';
238
-        $str = '<table id="table_with_attributes" class="attributes" ' . $summary . '>';
239
-        $str .= "\n" . '<caption>' . $translator->t('{consent:consent:table_caption}') . '</caption>';
238
+        $str = '<table id="table_with_attributes" class="attributes" '.$summary.'>';
239
+        $str .= "\n".'<caption>'.$translator->t('{consent:consent:table_caption}').'</caption>';
240 240
     }
241 241
 
242 242
     foreach ($attributes as $name => $value) {
243 243
         $nameraw = $name;
244
-        $name = $translator->getAttributeTranslation($parentStr . $nameraw);
244
+        $name = $translator->getAttributeTranslation($parentStr.$nameraw);
245 245
 
246 246
         if (preg_match('/^child_/', $nameraw)) {
247 247
             // insert child table
248 248
             $parentName = preg_replace('/^child_/', '', $nameraw);
249 249
             foreach ($value as $child) {
250
-                $str .= "\n" . '<tr class="odd"><td class="td_odd">' .
251
-                    present_attributes($t, $child, $parentName) . '</td></tr>';
250
+                $str .= "\n".'<tr class="odd"><td class="td_odd">'.
251
+                    present_attributes($t, $child, $parentName).'</td></tr>';
252 252
             }
253 253
         } else {
254 254
             // insert values directly
255 255
 
256
-            $str .= "\n" . '<tr class="' . $alternate[($i++ % 2)] .
257
-                '"><td><span class="attrname">' . htmlspecialchars($name) . '</span></td>';
256
+            $str .= "\n".'<tr class="'.$alternate[($i++ % 2)].
257
+                '"><td><span class="attrname">'.htmlspecialchars($name).'</span></td>';
258 258
 
259 259
             $isHidden = in_array($nameraw, $t->data['hiddenAttributes'], true);
260 260
             if ($isHidden) {
261 261
                 $hiddenId = \SimpleSAML\Utils\Random::generateID();
262
-                $str .= '<td><span class="attrvalue hidden" id="hidden_' . $hiddenId . '">';
262
+                $str .= '<td><span class="attrvalue hidden" id="hidden_'.$hiddenId.'">';
263 263
             } else {
264 264
                 $hiddenId = '';
265 265
                 $str .= '<td><span class="attrvalue">';
@@ -270,18 +270,18 @@  discard block
 block discarded – undo
270 270
                 $str .= '<ul>';
271 271
                 foreach ($value as $listitem) {
272 272
                     if ($nameraw === 'jpegPhoto') {
273
-                        $str .= '<li><img src="data:image/jpeg;base64,' .
274
-                            htmlspecialchars($listitem) . '" alt="User photo" /></li>';
273
+                        $str .= '<li><img src="data:image/jpeg;base64,'.
274
+                            htmlspecialchars($listitem).'" alt="User photo" /></li>';
275 275
                     } else {
276
-                        $str .= '<li>' . htmlspecialchars($listitem) . '</li>';
276
+                        $str .= '<li>'.htmlspecialchars($listitem).'</li>';
277 277
                     }
278 278
                 }
279 279
                 $str .= '</ul>';
280 280
             } elseif (isset($value[0])) {
281 281
                 // we hawe only one value
282 282
                 if ($nameraw === 'jpegPhoto') {
283
-                    $str .= '<img src="data:image/jpeg;base64,' .
284
-                        htmlspecialchars($value[0]) . '" alt="User photo" />';
283
+                    $str .= '<img src="data:image/jpeg;base64,'.
284
+                        htmlspecialchars($value[0]).'" alt="User photo" />';
285 285
                 } else {
286 286
                     $str .= htmlspecialchars($value[0]);
287 287
                 }
@@ -289,10 +289,10 @@  discard block
 block discarded – undo
289 289
             $str .= '</span>';
290 290
 
291 291
             if ($isHidden) {
292
-                $str .= '<div class="attrvalue consent_showattribute" id="visible_' . $hiddenId . '">';
292
+                $str .= '<div class="attrvalue consent_showattribute" id="visible_'.$hiddenId.'">';
293 293
                 $str .= '... ';
294
-                $str .= '<a class="consent_showattributelink" href="javascript:SimpleSAML_show(\'hidden_' . $hiddenId;
295
-                $str .= '\'); SimpleSAML_hide(\'visible_' . $hiddenId . '\');">';
294
+                $str .= '<a class="consent_showattributelink" href="javascript:SimpleSAML_show(\'hidden_'.$hiddenId;
295
+                $str .= '\'); SimpleSAML_hide(\'visible_'.$hiddenId.'\');">';
296 296
                 $str .= $translator->t('{consent:consent:show_attribute}');
297 297
                 $str .= '</a>';
298 298
                 $str .= '</div>';
Please login to merge, or discard this patch.
lib/Consent/Store/Cookie.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -42,19 +42,19 @@  discard block
 block discarded – undo
42 42
     {
43 43
         $cookieName = self::getCookieName($userId, $destinationId);
44 44
 
45
-        $data = $userId . ':' . $attributeSet . ':' . $destinationId;
45
+        $data = $userId.':'.$attributeSet.':'.$destinationId;
46 46
 
47
-        \SimpleSAML\Logger::debug('Consent cookie - Get [' . $data . ']');
47
+        \SimpleSAML\Logger::debug('Consent cookie - Get ['.$data.']');
48 48
 
49 49
         if (!array_key_exists($cookieName, $_COOKIE)) {
50 50
             \SimpleSAML\Logger::debug(
51
-                'Consent cookie - no cookie with name \'' . $cookieName . '\'.'
51
+                'Consent cookie - no cookie with name \''.$cookieName.'\'.'
52 52
             );
53 53
             return false;
54 54
         }
55 55
         if (!is_string($_COOKIE[$cookieName])) {
56 56
             \SimpleSAML\Logger::warning(
57
-                'Value of consent cookie wasn\'t a string. Was: ' .
57
+                'Value of consent cookie wasn\'t a string. Was: '.
58 58
                 var_export($_COOKIE[$cookieName], true)
59 59
             );
60 60
             return false;
@@ -92,9 +92,9 @@  discard block
 block discarded – undo
92 92
     public function saveConsent(string $userId, string $destinationId, string $attributeSet)
93 93
     {
94 94
         $name = self::getCookieName($userId, $destinationId);
95
-        $value = $userId . ':' . $attributeSet . ':' . $destinationId;
95
+        $value = $userId.':'.$attributeSet.':'.$destinationId;
96 96
 
97
-        \SimpleSAML\Logger::debug('Consent cookie - Set [' . $value . ']');
97
+        \SimpleSAML\Logger::debug('Consent cookie - Set ['.$value.']');
98 98
 
99 99
         $value = self::sign($value);
100 100
         return $this->setConsentCookie($name, $value);
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
             $tmp = explode(':', $value, 3);
165 165
             if (count($tmp) !== 3) {
166 166
                 \SimpleSAML\Logger::warning(
167
-                    'Consent cookie with invalid value: ' . $value
167
+                    'Consent cookie with invalid value: '.$value
168 168
                 );
169 169
                 continue;
170 170
             }
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
     {
196 196
         $secretSalt = \SimpleSAML\Utils\Config::getSecretSalt();
197 197
 
198
-        return sha1($secretSalt . $data . $secretSalt) . ':' . $data;
198
+        return sha1($secretSalt.$data.$secretSalt).':'.$data;
199 199
     }
200 200
 
201 201
 
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
      */
240 240
     private static function getCookieName(string $userId, string $destinationId)
241 241
     {
242
-        return '\SimpleSAML\Module\consent:' . sha1($userId . ':' . $destinationId);
242
+        return '\SimpleSAML\Module\consent:'.sha1($userId.':'.$destinationId);
243 243
     }
244 244
 
245 245
 
Please login to merge, or discard this patch.
lib/Consent/Store/Database.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -169,8 +169,8 @@  discard block
 block discarded – undo
169 169
     public function hasConsent(string $userId, string $destinationId, string $attributeSet)
170 170
     {
171 171
         $st = $this->execute(
172
-            'UPDATE ' . $this->table . ' ' .
173
-            'SET usage_date = ' . $this->dateTime . ' ' .
172
+            'UPDATE '.$this->table.' '.
173
+            'SET usage_date = '.$this->dateTime.' '.
174 174
             'WHERE hashed_user_id = ? AND service_id = ? AND attribute = ?',
175 175
             [$userId, $destinationId, $attributeSet]
176 176
         );
@@ -206,8 +206,8 @@  discard block
 block discarded – undo
206 206
     {
207 207
         // Check for old consent (with different attribute set)
208 208
         $st = $this->execute(
209
-            'UPDATE ' . $this->table . ' ' .
210
-            'SET consent_date = ' . $this->dateTime . ', usage_date = ' . $this->dateTime . ', attribute = ? ' .
209
+            'UPDATE '.$this->table.' '.
210
+            'SET consent_date = '.$this->dateTime.', usage_date = '.$this->dateTime.', attribute = ? '.
211 211
             'WHERE hashed_user_id = ? AND service_id = ?',
212 212
             [$attributeSet, $userId, $destinationId]
213 213
         );
@@ -224,8 +224,8 @@  discard block
 block discarded – undo
224 224
 
225 225
         // Add new consent
226 226
         $st = $this->execute(
227
-            'INSERT INTO ' . $this->table . ' (' . 'consent_date, usage_date, hashed_user_id, service_id, attribute' .
228
-            ') ' . 'VALUES (' . $this->dateTime . ', ' . $this->dateTime . ', ?, ?, ?)',
227
+            'INSERT INTO '.$this->table.' ('.'consent_date, usage_date, hashed_user_id, service_id, attribute'.
228
+            ') '.'VALUES ('.$this->dateTime.', '.$this->dateTime.', ?, ?, ?)',
229 229
             [$userId, $destinationId, $attributeSet]
230 230
         );
231 231
 
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
     public function deleteConsent(string $userId, string $destinationId)
250 250
     {
251 251
         $st = $this->execute(
252
-            'DELETE FROM ' . $this->table . ' WHERE hashed_user_id = ? AND service_id = ?;',
252
+            'DELETE FROM '.$this->table.' WHERE hashed_user_id = ? AND service_id = ?;',
253 253
             [$userId, $destinationId]
254 254
         );
255 255
 
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
     public function deleteAllConsents(string $userId)
278 278
     {
279 279
         $st = $this->execute(
280
-            'DELETE FROM ' . $this->table . ' WHERE hashed_user_id = ?',
280
+            'DELETE FROM '.$this->table.' WHERE hashed_user_id = ?',
281 281
             [$userId]
282 282
         );
283 283
 
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
         }
287 287
 
288 288
         if ($st->rowCount() > 0) {
289
-            \SimpleSAML\Logger::debug('consent:Database - Deleted (' . $st->rowCount() . ') consent(s) . ');
289
+            \SimpleSAML\Logger::debug('consent:Database - Deleted ('.$st->rowCount().') consent(s) . ');
290 290
             return $st->rowCount();
291 291
         }
292 292
 
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
         $ret = [];
310 310
 
311 311
         $st = $this->execute(
312
-            'SELECT service_id, attribute, consent_date, usage_date FROM ' . $this->table .
312
+            'SELECT service_id, attribute, consent_date, usage_date FROM '.$this->table.
313 313
             ' WHERE hashed_user_id = ?',
314 314
             [$userId]
315 315
         );
@@ -348,16 +348,16 @@  discard block
 block discarded – undo
348 348
         $st = $db->prepare($statement);
349 349
         if ($st === false) {
350 350
             \SimpleSAML\Logger::error(
351
-                'consent:Database - Error preparing statement \'' .
352
-                $statement . '\': ' . self::formatError($db->errorInfo())
351
+                'consent:Database - Error preparing statement \''.
352
+                $statement.'\': '.self::formatError($db->errorInfo())
353 353
             );
354 354
             return false;
355 355
         }
356 356
 
357 357
         if ($st->execute($parameters) !== true) {
358 358
             \SimpleSAML\Logger::error(
359
-                'consent:Database - Error executing statement \'' .
360
-                $statement . '\': ' . self::formatError($st->errorInfo())
359
+                'consent:Database - Error executing statement \''.
360
+                $statement.'\': '.self::formatError($st->errorInfo())
361 361
             );
362 362
             return false;
363 363
         }
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
         $ret = [];
382 382
 
383 383
         // Get total number of consents
384
-        $st = $this->execute('SELECT COUNT(*) AS no FROM ' . $this->table, []);
384
+        $st = $this->execute('SELECT COUNT(*) AS no FROM '.$this->table, []);
385 385
 
386 386
         if ($st === false) {
387 387
             return [];
@@ -393,8 +393,8 @@  discard block
 block discarded – undo
393 393
 
394 394
         // Get total number of users that has given consent
395 395
         $st = $this->execute(
396
-            'SELECT COUNT(*) AS no ' .
397
-            'FROM (SELECT DISTINCT hashed_user_id FROM ' . $this->table . ' ) AS foo',
396
+            'SELECT COUNT(*) AS no '.
397
+            'FROM (SELECT DISTINCT hashed_user_id FROM '.$this->table.' ) AS foo',
398 398
             []
399 399
         );
400 400
 
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
 
409 409
         // Get total number of services that has been given consent to
410 410
         $st = $this->execute(
411
-            'SELECT COUNT(*) AS no FROM (SELECT DISTINCT service_id FROM ' . $this->table . ') AS foo',
411
+            'SELECT COUNT(*) AS no FROM (SELECT DISTINCT service_id FROM '.$this->table.') AS foo',
412 412
             []
413 413
         );
414 414
 
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
     {
465 465
         Assert::greaterThanEq(count($error), 3);
466 466
 
467
-        return $error[0] . ' - ' . $error[2] . ' (' . $error[1] . ')';
467
+        return $error[0].' - '.$error[2].' ('.$error[1].')';
468 468
     }
469 469
 
470 470
 
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
     public function selftest()
477 477
     {
478 478
         $st = $this->execute(
479
-            'SELECT * FROM ' . $this->table . ' WHERE hashed_user_id = ? AND service_id = ? AND attribute = ?',
479
+            'SELECT * FROM '.$this->table.' WHERE hashed_user_id = ? AND service_id = ? AND attribute = ?',
480 480
             ['test', 'test', 'test']
481 481
         );
482 482
 
Please login to merge, or discard this patch.