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.

SentinelGuardServiceProvider::boot()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 0
cts 7
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
namespace Rojtjo\SentinelGuard;
4
5
use Cartalyst\Sentinel\Sentinel;
6
use Illuminate\Auth\AuthManager;
7
use Illuminate\Support\ServiceProvider;
8
use Symfony\Component\HttpFoundation\Response;
9
10
class SentinelGuardServiceProvider extends ServiceProvider
11
{
12
    /**
13
     * @param AuthManager $auth
14
     */
15
    public function boot(AuthManager $auth)
16
    {
17
        $auth->extend('sentinel', function () {
18
            return new SentinelGuard(
19
                $this->app->make(GuardableSentinel::class)
20
            );
21
        });
22
    }
23
24
    /**
25
     * @return void
26
     */
27
    public function register()
28
    {
29
        $this->app->singleton('sentinel', function ($app) {
30
            $sentinel = new GuardableSentinel(
31
                $app['sentinel.persistence'],
32
                $app['sentinel.users'],
33
                $app['sentinel.roles'],
34
                $app['sentinel.activations'],
35
                $app['events']
36
            );
37
38
            if (isset($app['sentinel.checkpoints'])) {
39
                foreach ($app['sentinel.checkpoints'] as $key => $checkpoint) {
40
                    $sentinel->addCheckpoint($key, $checkpoint);
41
                }
42
            }
43
44
            $sentinel->setActivationRepository($app['sentinel.activations']);
45
            $sentinel->setReminderRepository($app['sentinel.reminders']);
46
47
            $sentinel->setRequestCredentials(function () use ($app) {
48
                $request = $app['request'];
49
50
                $login = $request->getUser();
51
                $password = $request->getPassword();
52
53
                if ($login === null && $password === null) {
54
                    return;
55
                }
56
57
                return compact('login', 'password');
58
            });
59
60
            $sentinel->creatingBasicResponse(function () {
61
                $headers = ['WWW-Authenticate' => 'Basic'];
62
63
                return new Response('Invalid credentials.', 401, $headers);
64
            });
65
66
            return $sentinel;
67
        });
68
69
        $this->app->alias('sentinel', GuardableSentinel::class);
70
        $this->app->alias(Sentinel::class, GuardableSentinel::class);
71
    }
72
}
73