HomeController   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 5
Bugs 2 Features 1
Metric Value
wmc 4
eloc 13
c 5
b 2
f 1
dl 0
loc 45
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A index() 0 19 3
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
     * @var PullRequestChecker
14
     */
15
    protected $checker;
16
17
18
    /**
19
     * Create a new controller instance.
20
     *
21
     * @param PullRequestChecker $checker
22
     */
23
    public function __construct(PullRequestChecker $checker)
24
    {
25
        $this->checker = $checker;
26
    }
27
28
    /**
29
     * Display the current status if the user already signed in via GitHubs' OAuth API.
30
     * Display some infotext and the sign in button otherwise.
31
     *
32
     * @return \Illuminate\View\View
33
     */
34
    public function index()
35
    {
36
        if (!Auth::check()) {
37
            return view('index');
38
        }
39
40
        $user = Auth::user();
41
        $prs = $this->checker->getQualifiedPullRequests($user);
42
43
        $message = "I'm about to start hacking for Hacktoberfest!";
44
45
        if ($prs->total_count > 0) {
46
            $message = "I've completed $prs->total_count pull requests for Hacktoberfest!";
47
        }
48
49
        $viewData = compact('user', 'prs', 'message');
50
        $viewData['sharingMode'] = $this->sharingMode;
51
52
        return view('status', $viewData);
53
    }
54
}
55