GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

AuthController::doLogout()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Serverfireteam\Panel;
4
5
use Illuminate\Support\Facades\Session as session;
6
use Illuminate\Routing\Controller;
7
use Illuminate\Support\Facades\Input;
8
9
class AuthController extends Controller {
10
11
    /**
12
     * Display the password reminder view.
13
     *
14
     * @return Response
15
     */
16
    public function postLogin()
17
    {
18
19
        $userdata = array(
20
                'email' 	=> Input::get('email'),
21
                'password' 	=> Input::get('password')
22
        );
23
        // attempt to do the login
24
        if (\Auth::guard('panel')->attempt($userdata,filter_var(Input::get('remember'), FILTER_VALIDATE_BOOLEAN))) {
25
            return \Redirect::to('panel');
0 ignored issues
show
Bug Best Practice introduced by
The return type of return \Redirect::to('panel'); (Illuminate\Http\RedirectResponse) is incompatible with the return type documented by Serverfireteam\Panel\AuthController::postLogin of type Serverfireteam\Panel\Response.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
26
        } else {
27
            // validation not successful, send back to form	
28
            return \Redirect::to('panel/login')->with('message', \Lang::get('panel::fields.passwordNotCorrect') )->with('mesType','error');
29
        }
30
    }
31
    
32
    public function getLogin(){
33
        
34
        $message = (\Session::has('message') ? \Session::get('message') : \Lang::get('panel::fields.signIn'));
35
        $mesType = (\Session::has('mesType') ? \Session::get('mesType') : 'message');
36
        return \View::make('panelViews::login')->with('message', $message)->with('mesType', $mesType);
37
    }
38
    
39
    public function doLogout(){
40
        
41
        \Auth::guard('panel')->logout();     
42
        return \Redirect::to('panel/login');
43
    }
44
}