GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

CorsServiceProvider   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 3
dl 0
loc 31
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 16 4
A register() 0 6 2
A isLaravel() 0 4 1
1
<?php
2
3
namespace Spatie\Cors;
4
5
use Illuminate\Support\ServiceProvider;
6
use Spatie\Cors\CorsProfile\CorsProfile;
7
use Spatie\Cors\CorsProfile\DefaultProfile;
8
use Spatie\Cors\Exceptions\InvalidCorsProfile;
9
10
class CorsServiceProvider extends ServiceProvider
11
{
12
    public function boot()
13
    {
14
        if ($this->isLaravel() && $this->app->runningInConsole()) {
15
            $this->publishes([
16
                __DIR__.'/../config/cors.php' => config_path('cors.php'),
17
            ], 'config');
18
        }
19
20
        $configuredCorsProfile = config('cors.cors_profile');
21
22
        if (! is_a($configuredCorsProfile, DefaultProfile::class, true)) {
23
            throw InvalidCorsProfile::profileDoesNotExtendDefaultProfile($configuredCorsProfile);
24
        }
25
26
        $this->app->bind(CorsProfile::class, $configuredCorsProfile);
27
    }
28
29
    public function register()
30
    {
31
        if ($this->isLaravel()) {
32
            $this->mergeConfigFrom(__DIR__.'/../config/cors.php', 'cors');
33
        }
34
    }
35
36
    protected function isLaravel()
37
    {
38
        return ! preg_match('/lumen/i', app()->version());
39
    }
40
}
41