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   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 6
dl 0
loc 63
ccs 0
cts 40
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 8 1
B register() 0 45 5
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