EvernoteAuthController   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 5
c 2
b 0
f 1
lcom 0
cbo 5
dl 0
loc 49
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A login() 0 11 2
A callback() 0 20 3
1
<?php
2
3
class EvernoteAuthController extends Controller {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
4
5
    /**
6
     * @var array
7
     */
8
    private static $allowed_actions = array(
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
Unused Code introduced by
The property $allowed_actions is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
9
        'login','callback',
10
    );
11
12
    /**
13
     * authenticate with Evernote
14
     */
15
    public function login() {
16
17
        if( $member = Member::currentUser() ) {
0 ignored issues
show
Unused Code introduced by
$member is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
18
            $Evernote = new Evernote();
19
            $Evernote->Authorize();
20
21
        } else {
22
23
            $this->redirect('Security/login/?back=evernote-auth/login');
24
        }
25
    }
26
27
    /**
28
     * store token from Evernote and redirect to given url or redirect to home page
29
     */
30
    public function callback() {
31
32
        if( $member = Member::currentUser() ) {
33
            $Evernote = new Evernote();
34
            $Token = $Evernote->Authorize();
35
36
            $member->EvernoteToken = $Token;
37
            $member->write();
38
39
            $EvernoteSettings = EvernoteSettings::current_Evernote_settings();
40
41
            $url = (!empty($EvernoteSettings->CallbackURL)) ?: '/';
42
43
            $this->redirect($url);
44
45
        } else {
46
47
            $this->redirect('Security/login/?back=evernote-auth/login');
48
        }
49
    }
50
51
}