Service   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 20
c 2
b 0
f 0
dl 0
loc 37
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A provides() 0 3 1
A register() 0 5 1
A boot() 0 14 2
1
<?php namespace GeneaLabs\LaravelMixpanel\Providers;
2
3
use GeneaLabs\LaravelMixpanel\LaravelMixpanel;
4
use GeneaLabs\LaravelMixpanel\Listeners\Login as LoginListener;
5
use GeneaLabs\LaravelMixpanel\Listeners\LoginAttempt;
6
use GeneaLabs\LaravelMixpanel\Listeners\Logout as LogoutListener;
7
use GeneaLabs\LaravelMixpanel\Listeners\LaravelMixpanelUserObserver;
8
use GeneaLabs\LaravelMixpanel\Console\Commands\Publish;
9
use GeneaLabs\LaravelMixpanel\Events\MixpanelEvent;
10
use GeneaLabs\LaravelMixpanel\Listeners\MixpanelEvent as MixpanelEventListener;
11
use Illuminate\Contracts\View\View;
12
use Illuminate\Auth\Events\Attempting;
13
use Illuminate\Auth\Events\Login;
14
use Illuminate\Auth\Events\Logout;
15
use Illuminate\HTTP\Request;
16
use Illuminate\Support\ServiceProvider;
17
use Illuminate\Foundation\Support\Providers\EventServiceProvider;
18
19
class Service extends EventServiceProvider
20
{
21
    protected $defer = false;
22
    protected $listen = [
23
        MixpanelEvent::class => [MixpanelEventListener::class],
24
        Attempting::class => [LoginAttempt::class],
25
        Login::class => [LoginListener::class],
26
        Logout::class => [LogoutListener::class],
27
    ];
28
29
    public function boot()
30
    {
31
        parent::boot();
32
33
        include __DIR__ . '/../../routes/api.php';
34
35
        $this->loadViewsFrom(__DIR__ . '/../../resources/views', 'genealabs-laravel-mixpanel');
36
        $this->publishes([
37
            __DIR__ . '/../../public' => public_path(),
38
        ], 'assets');
39
40
        if (config('services.mixpanel.enable-default-tracking')) {
41
            $authModel = config('auth.providers.users.model') ?? config('auth.model');
42
            $this->app->make($authModel)->observe(new LaravelMixpanelUserObserver());
43
        }
44
    }
45
46
    public function register()
47
    {
48
        $this->mergeConfigFrom(__DIR__ . '/../../config/services.php', 'services');
49
        $this->commands(Publish::class);
50
        $this->app->singleton('mixpanel', LaravelMixpanel::class);
51
    }
52
53
    public function provides() : array
54
    {
55
        return ['genealabs-laravel-mixpanel'];
56
    }
57
}
58