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.

CheckForReadOnlyMode   A
last analyzed

Complexity

Total Complexity 12

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
C handle() 0 31 12
1
<?php
2
3
namespace Rappasoft\Lockout\Http\Middleware;
4
5
use Closure;
6
use Illuminate\Http\Response;
7
8
/**
9
 * Class CheckForReadOnlyMode.
10
 */
11
class CheckForReadOnlyMode
12
{
13
    /**
14
     * @param $request
15
     * @param  Closure  $next
16
     *
17
     * @return mixed
18
     */
19 13
    public function handle($request, Closure $next)
20
    {
21 13
        if (config('lockout.enabled')) {
22
            // Check to see if this method and path is whitelisted
23 8
            foreach (config('lockout.whitelist') as $method => $path) {
24 1
                if ($request->isMethod($method) && $request->path() === $path) {
25 1
                    return $next($request);
26
                }
27
            }
28
29 8
            foreach (config('lockout.locked_types', []) as $type) {
30 7
                if ($request->isMethod('post') && config('lockout.allow_login')) {
31 1
                    abort_if($request->path() !== config('lockout.login_path') && $request->path() !== config('lockout.logout_path'), Response::HTTP_UNAUTHORIZED);
32 6
                } elseif ($request->isMethod(strtolower($type))) {
33 6
                    abort(Response::HTTP_UNAUTHORIZED);
34
                }
35
            }
36
37
            // Block any other specific get requests that may alter data
38 2
            if ($request->isMethod('get')) {
39 1
                collect(config('lockout.pages', []))
40 1
                    ->each(function ($item) use ($request) {
41 1
                        if ($request->path() === $item) {
42 1
                            abort(Response::HTTP_UNAUTHORIZED);
43
                        }
44 1
                    });
45
            }
46
        }
47
48 6
        return $next($request);
49
    }
50
}
51