Completed
Push — master ( 5a053e...8eeafe )
by Terrence
10:16
created

index.php ➔ getUserAndRespond()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 99

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 99
rs 8.0218
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
// error_reporting(E_ALL); ini_set('display_errors',1);
4
5
require_once __DIR__ . '/../vendor/autoload.php';
6
require_once __DIR__ . '/index-functions.php';
7
8
use CILogon\Service\Util;
9
10
Util::startPHPSession();
11
12
// Check the csrf cookie against either a hidden <form> element or a
13
// PHP session variable, and get the value of the 'submit' element.
14
$submit = Util::getCsrf()->verifyCookieAndGetSubmit();
15
Util::unsetSessionVar('submit');
16
17
// Get the URL to reply to after database query.
18
$responseurl = Util::getSessionVar('responseurl');
19
20
21
if (
22
    ($submit == 'getuser') &&
23
    (strlen($responseurl) > 0) &&
24
    (strlen(Util::getGetVar('state')) > 0)
25
) {
26
    getUserAndRespond();
27
} else {
28
    // If responseurl is empty, simply redirect to main site
29
    if (strlen($responseurl) == 0) {
30
        $responseurl = 'https://' . Util::getHN();
31
    }
32
}
33
34
// Finally, redirect to the calling script.
35
header('Location: ' . $responseurl);
36
exit; // No further processing necessary
37