Authorize   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 16
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 5 2
A allowedToUseTinker() 0 7 2
1
<?php
2
3
namespace Spatie\WebTinker\Http\Middleware;
4
5
use Illuminate\Support\Facades\Gate;
6
7
class Authorize
8
{
9
    public function handle($request, $next)
10
    {
11
        return $this->allowedToUseTinker()
12
            ? $next($request)
13
            : abort(403);
0 ignored issues
show
Bug introduced by freek
Are you sure the usage of abort(403) is correct as it seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
14
    }
15
16
    protected function allowedToUseTinker(): bool
17
    {
18
        if (! config('web-tinker.enabled')) {
19
            return false;
20
        }
21
22
        return Gate::check('viewWebTinker');
23
    }
24
}
25