AuthenticationLogServiceProvider   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 26
c 1
b 0
f 0
dl 0
loc 64
rs 10
wmc 7

3 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 5 2
A registerEvents() 0 7 3
A boot() 0 26 2
1
<?php
2
3
namespace Yadahan\AuthenticationLog;
4
5
use Illuminate\Contracts\Events\Dispatcher;
6
use Illuminate\Support\ServiceProvider;
7
8
class AuthenticationLogServiceProvider extends ServiceProvider
9
{
10
    use EventMap;
11
12
    /**
13
     * Bootstrap the application services.
14
     *
15
     * @return void
16
     */
17
    public function boot()
18
    {
19
        $this->registerEvents();
20
21
        $this->loadViewsFrom(__DIR__.'/../resources/views', 'authentication-log');
22
23
        $this->loadTranslationsFrom(__DIR__.'/../resources/lang', 'authentication-log');
24
25
        $this->mergeConfigFrom(__DIR__.'/../config/authentication-log.php', 'authentication-log');
26
27
        if ($this->app->runningInConsole()) {
28
            $this->publishes([
29
                __DIR__.'/../database/migrations' => database_path('migrations'),
30
            ], 'authentication-log-migrations');
31
32
            $this->publishes([
33
                __DIR__.'/../resources/views' => resource_path('views/vendor/authentication-log'),
34
            ], 'authentication-log-views');
35
36
            $this->publishes([
37
                __DIR__.'/../resources/lang' => resource_path('lang/vendor/authentication-log'),
38
            ], 'authentication-log-translations');
39
40
            $this->publishes([
41
                __DIR__.'/../config/authentication-log.php' => config_path('authentication-log.php'),
42
            ], 'authentication-log-config');
43
        }
44
    }
45
46
    /**
47
     * Register the Authentication Log's events.
48
     *
49
     * @return void
50
     */
51
    protected function registerEvents()
52
    {
53
        $events = $this->app->make(Dispatcher::class);
54
55
        foreach ($this->events as $event => $listeners) {
56
            foreach ($listeners as $listener) {
57
                $events->listen($event, $listener);
58
            }
59
        }
60
    }
61
62
    /**
63
     * Register the application services.
64
     *
65
     * @return void
66
     */
67
    public function register()
68
    {
69
        if ($this->app->runningInConsole()) {
70
            $this->commands([
71
                Console\ClearCommand::class,
72
            ]);
73
        }
74
    }
75
}
76