Authorization   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 18
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 7 2
1
<?php
2
3
namespace Yab\FlightDeck\Http\Middleware;
4
5
use Closure;
6
use Yab\FlightDeck\FlightDeck;
7
use Illuminate\Auth\Access\AuthorizationException;
8
9
class Authorization
10
{
11
    /**
12
     * Handle an incoming request.
13
     *
14
     * @param  \Illuminate\Http\Request  $request
15
     * @param  \Closure  $next
16
     *
17
     * @return mixed
18
     */
19
    public function handle($request, Closure $next)
20
    {
21
        if (FlightDeck::checkToken($request->header(config('flightdeck.authorization.header')))) {
0 ignored issues
show
Bug introduced by
It seems like $request->header(config(...authorization.header')) targeting Illuminate\Http\Concerns...actsWithInput::header() can also be of type array; however, Yab\FlightDeck\FlightDeck::checkToken() does only seem to accept null|string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
22
            return $next($request);
23
        }
24
        throw new AuthorizationException('You have provided an invalid api token.');
25
    }
26
}
27