callback   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 1
c 3
b 0
f 1
lcom 0
cbo 4
dl 0
loc 31
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B doGet() 0 28 1
1
<?php
2
3
namespace cvweiss\projectbase\Controller\auth\eve;
4
5
use zkillboard\crestsso\CrestSSO;
6
use cvweiss\projectbase\Config;
7
use cvweiss\projectbase\Mongo;
8
use cvweiss\projectbase\Session;
9
10
class callback
11
{
12
    public function doGet($view, $params)
13
    { 
14
        unset($params);
15
        $auth = Config::getInstance()->get("oauth2");
16
        $eve = $auth['eve'];
17
18
        $sso = new CrestSSO($eve['client_id'], $eve['client_secret'], $eve['redirect_uris'][0], $eve['scopes'], '/');
19
        $code = filter_input(INPUT_GET, 'code');
20
        $state = filter_input(INPUT_GET, 'state');
21
        $userInfo = $sso->handleCallback($code, $state, Session::getSession());
0 ignored issues
show
Unused Code introduced by
The call to CrestSSO::handleCallback() has too many arguments starting with $state.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
22
23
        $charID = $userInfo['characterID'];
24
        $id = "auth:eve:" . $charID;
25
        $user = Mongo::get()->findDoc("users", ['id' => $id], null, true);
26
27
        $user->setAll([
28
                "id" => $id,
29
                "name" => $userInfo['characterName'],
30
                "email" => null,
31
                "image" => "https://imageserver.eveonline.com/Character/${charID}_256.jpg",
32
                "oauth2" => "eve",
33
                "refresh_token" => $userInfo['refreshToken']
34
        ]);
35
        $user->save();
36
37
        Session::getSession()->set("userID", $id);
38
        $view->redirect('/', 302);
39
    }
40
}
41