Cors   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 13 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 Cors
10
{
11
    /**
12
     * Handle an incoming request.
13
     *
14
     * @param  \Illuminate\Http\Request  $request
15
     * @param  \Closure  $next
16
     * @return mixed
17
     */
18
    public function handle($request, Closure $next)
19
    {
20
        $content = $next($request);
21
22
        if (method_exists($content, 'header')) {
23
            return $content
24
                ->header('Access-Control-Allow-Origin', config('flightdeck.cors.origin'))
25
                ->header('Access-Control-Allow-Methods', config('flightdeck.cors.methods'))
26
                ->header('Access-Control-Allow-Headers', 'Origin, Content-Type, Accept, Authorization, Cache-Control, X-Requested-With');
27
        }
28
29
        return $content;
30
    }
31
}
32