Authorize::handle()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
c 0
b 0
f 0
nc 2
nop 2
dl 0
loc 5
rs 10
1
<?php
2
3
namespace BeyondCode\LaravelWebSockets\Dashboard\Http\Middleware;
4
5
use Illuminate\Support\Facades\Gate;
6
7
class Authorize
8
{
9
    /**
10
     * Authorize the current user.
11
     *
12
     * @param  \Illuminate\Http\Request  $request
13
     * @param  \Closure  $next
14
     * @return \Illuminate\Http\Response
15
     */
16
    public function handle($request, $next)
17
    {
18
        return Gate::check('viewWebSocketsDashboard', [$request->user()])
19
            ? $next($request)
20
            : abort(403);
0 ignored issues
show
Bug introduced by
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...
21
    }
22
}
23