Completed
Push — master ( 304033...9e211f )
by Chris
20s
created

Cors   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
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 3
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 (config('flightdeck.cors.enabled') && method_exists($content, 'header')) {
23
            return $content
24
                ->header('Access-Control-Allow-Origin', '*')
25
                ->header('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE')
26
                ->header('Access-Control-Allow-Headers', 'Origin, Content-Type, Accept, Authorization, Cache-Control, X-Requested-With');
27
        }
28
29
        return $content;
30
    }
31
}
32