RefererServiceProvider::boot()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Spatie\Referer;
4
5
use Illuminate\Support\ServiceProvider;
6
7
class RefererServiceProvider extends ServiceProvider
8
{
9
    /**
10
     * Bootstrap the application services.
11
     */
12
    public function boot()
13
    {
14
        $this->publishes([
15
            __DIR__.'/../config/referer.php' => config_path('referer.php'),
16
        ], 'config');
17
    }
18
19
    /**
20
     * Register the application services.
21
     */
22
    public function register()
23
    {
24
        $this->mergeConfigFrom(__DIR__.'/../config/referer.php', 'referer');
25
26
        $this->app->when(Referer::class)
27
            ->needs('$sessionKey')
28
            ->give(function () {
29
                return $this->app['config']->get('referer.session_key');
30
            });
31
32
        $this->app->when(Referer::class)
33
            ->needs('$sources')
34
            ->give(function () {
35
                return $this->app['config']->get('referer.sources', []);
36
            });
37
38
        $this->app->singleton(Referer::class);
39
        $this->app->alias(Referer::class, 'referer');
40
    }
41
}
42