Completed
Push — develop ( 06396b...c3acb5 )
by Niclas Leon
12s
created

HomeController   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 2
Bugs 2 Features 1
Metric Value
dl 0
loc 38
c 2
b 2
f 1
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A index() 0 14 2
1
<?php
2
3
namespace App\Http\Controllers;
4
5
use Auth;
6
use App\Hacktoberfest\GitHub\PullRequestChecker;
7
8
class HomeController extends Controller
9
{
10
    /**
11
     * Instance of the 'pull request checker'.
12
     */
13
    protected $checker;
14
15
    /**
16
     * Create a new controller instance.
17
     *
18
     * @param PullRequestChecker $checker
19
     * @internal param PullRequestChecker $prChecker
20
     */
21
    public function __construct(PullRequestChecker $checker)
22
    {
23
        $this->checker = $checker;
24
    }
25
26
    /**
27
     * Display the current status if the user already signed in via GitHubs' OAuth API.
28
     * Display some infotext and the sign in button otherwise.
29
     *
30
     * @return Illuminate\View\View
0 ignored issues
show
Bug introduced by
The type App\Http\Controllers\Illuminate\View\View was not found. Did you mean Illuminate\View\View? If so, make sure to prefix the type with \.
Loading history...
31
     */
32
    public function index()
33
    {
34
        if (Auth::check()) {
35
            $user = Auth::user();
36
37
            $prs = $this->checker->getQualifiedPullRequests($user);
38
39
            return view('status', [
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('status', ar... $user, 'prs' => $prs)) returns the type Illuminate\View\View which is incompatible with the documented return type App\Http\Controllers\Illuminate\View\View.
Loading history...
40
                'user' => $user,
41
                'prs' => $prs
42
            ]);
43
        }
44
45
        return view('index');
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('index') returns the type Illuminate\View\View which is incompatible with the documented return type App\Http\Controllers\Illuminate\View\View.
Loading history...
46
    }
47
}
48