LaravelCorsServiceProvider   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 27
ccs 8
cts 8
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 6 1
A boot() 0 5 1
1
<?php
2
3
namespace ShiftOneLabs\LaravelCors;
4
5
use Illuminate\Contracts\Http\Kernel;
6
use Illuminate\Support\ServiceProvider;
7
use ShiftOneLabs\LaravelCors\Http\Middleware\CorsWrapper;
8
9
class LaravelCorsServiceProvider extends ServiceProvider
10
{
11
    /**
12
     * Bootstrap any application services.
13
     *
14
     * @param  \Illuminate\Foundation\Http\Kernel  $kernel
15
     *
16
     * @return void
17
     */
18 368
    public function boot(Kernel $kernel)
19
    {
20 368
        $this->publishes([__DIR__.'/../config/cors.php' => config_path('cors.php')], 'config');
21
22 368
        $kernel->prependMiddleware(CorsWrapper::class);
23 368
    }
24
25
    /**
26
     * Register any application services.
27
     *
28
     * @return void
29
     */
30 368
    public function register()
31
    {
32 368
        $this->mergeConfigFrom(__DIR__.'/../config/cors.php', 'cors');
33
34 368
        $this->app->singleton(CorsPolicyManager::class, function ($app) {
35 230
            return new CorsPolicyManager($app, $app['config']->get('cors'));
36 368
        });
37 368
    }
38
}
39