Completed
Push — develop ( 2d5252...0188b0 )
by Niclas Leon
12s
created

ShareController::index()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 11
rs 9.4285
cc 2
eloc 5
nc 2
nop 2
1
<?php
2
3
namespace App\Http\Controllers;
4
5
use App\Hacktoberfest\GitHub\PullRequestChecker;
6
use App\User;
7
8
class ShareController extends Controller
9
{
10
    /**
11
     * Display a user's PR status if user already authorized this app,
12
     * otherwise redirect to home page.
13
     *
14
     * @param PullRequestChecker $checker
15
     * @param $github_username
16
     * @return \Illuminate\Http\RedirectResponse|\Illuminate\View\View
17
     */
18
    public function index(PullRequestChecker $checker, $github_username)
19
    {
20
        $user = User::where('github_username', '=', $github_username)->first();
21
22
        if (!$user) {
23
            return redirect('/');
24
        }
25
26
        $prs = $checker->getQualifiedPullRequests($user);
27
28
        return view('status', compact('user', 'prs'));
29
    }
30
}
31